go from Network
1 $.ajax ({2Type: "POST",3URL: "Http://192.168.0.88/action.cgi?ActionID=WEB_RequestCertificateAPI",4 data: {5"User": "API",6"Password": "API"7 },8DataType: "JSON",9ContentType: "Application/json",TenBeforesend:function(XMLHttpRequest) { One //Httputility.urlencode A varSessionID = "SessionID"; - Xmlhttprequest.setrequestheader (SessionID, sid); - }, theSuccessfunction(SessionID) { - //alert (sessionid.success); - varDT = eval ("(" + Sessionid.data + ")"); - if(Sessionid.success = = 1) { +Alert ("Success"); - } + Else { AAlert (' ErrorID: ' +SessionID.error.id); atAlert (' ErrorCode: ' +SessionID.error.code); -Alert (' Errorpara: ' +SessionID.error.params); - } - } -});
For various reasons, in their own framework to pass the system agreed to the header information, the page uses the jquery Ajax request, looked for a long time, suddenly found that we can be set in the Beforesend method, this method accepts a parameter, Represents the XMLHttpRequest object that initiates an asynchronous request, and we can use the object's setRequestHeader method to achieve our purpose, for example, I add a custom datatype header message to the header:
Beforesend:function (XMLHttpRequest) {
Xmlhttprequest.setrequestheader ("DataType", "abc");
$ (". Return_confrim"). HTML (" Verifying account ... ");
},
In this way, we can get the datatype information in the customization on the server side.
Add custom header information to jquery Ajax