简体   繁体   English

我怎样才能将工作的JS代码转换为JQUERY

[英]How can I convert this working JS code to JQUERY

var xmlHttp;

function RefreshORP(eventTarget, eventArgument)
{

  xmlHttp = GetXmlHttpObject();
  if(xmlHttp == null)
  {
    return true;
  }

  xmlHttp.onreadystatechange = StateChanged;

  var params = GetFormParam(eventTarget,eventArgument); 

  xmlHttp.open("POST","/contact.jsp",true);

  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

  xmlHttp.setRequestHeader("ajaxcall", "true");

  xmlHttp.send(params);
}

In jQuery you have it all done... 在jQuery中,您已经完成了所有工作...

$.post("/contact.jsp", $("formID").serialize(), function(data){
    // process callback
});

jQuery will also set all appropriate (and somehow standardized) request headers. jQuery还将设置所有适当的(并且以某种方式标准化的)请求标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM