Recently I 've been playing with jeasyui. It's easy to use, but it's so convenient that it's less flexible.
When a DataGrid in jeasyui is used to request a WebService (asmx file), the following error occurs:
Local Development and debugging, can request data to the server normally;
After being published to IIS, the client cannot access the data;
Make a local access to the server and request data .)
When jquery Ajax is used to request a WebService (asmx file), it remains normal.
Development Environment: vs2008 in Windows XP
JS framework: jquery-1.7.2.min.js
Jquery. easyui. Min. js
View --------------- with firebug because the URL ends unexpectedly with "/xxxxxxxxxx", the request format cannot be identified.
Instructor Gu said:
Add the following content to the <system. Web> node of WebService::
<WebServices>
<Protocols>
<Add name = "httppost"/>
<Add name = "httpget"/>
</Protocols>
</WebServices>
Let's take a look at the two requests and the return process using firebug and compare the results,
Easyui DataGrid request:
Headers:
Responseheaders:
// Manually set context. response. contenttype = "application/JSON; charset = UTF-8" on the server side ";
// If this parameter is not set, the following content-type does not exist.
Server ASP. NET development server/9.0.0.0
Content-Type application/JSON; charset = UTF-8
Requestheaders:
Content-Type application/X-WWW-form-urlencoded; charset = UTF-8 // application/X-WWW-form-urlencoded (Form submitted using the http post method)
Accept application/JSON, text/JavaScript, */*; q = 0.01
X-requested-with XMLHttpRequest
Post:
Parameters: Application/X-WWW-form-urlencoded
Invs_id 1041 // This is a parameter,
JSON: // JSON has no data,
Source:
Invs_id = 1041 // note the format
Bytes -----------------------------------------------------------------------------------------------------
Jquery Ajax request:
Headers:
Responseheaders:
Server Microsoft-IIS/6.0
Responseheaders: Content-Type application/JSON; charset = UTF-8
Accept application/JSON, text/JavaScript, */*; q = 0.01
X-requested-with XMLHttpRequest
Post:
// Parameters
JSON // JSON has data
Invsid 1041 // This is a parameter
Source
{Invsid: 1041} // note the format
Easyui requests (jquery Ajax requests at the underlying layer). If Content-Type is not set, application/X-WWW-form-urlencoded is added by default;
Cause: Because the URL ends unexpectedly with "/xxxxxxxxxx", the request format cannot be identified. The reason must be that the Content-Type is application/X-WWW-form-urlencoded;
But why does the client fail to access the server when the local computer can request data? (......)