May 02, 2010, 2:34 PM
[CLOSED] Adding params as jsonData for jsin Ajax requests
I have hit into a major issue here. I make numerous Web Service json requests with method=POST. I thought that POST being the method, the params would be sent in the request body, and would NOt be appended to the Url. However, I just found that even for POST requests, the params are appended to the Url for json requests.
Digging deep into the code, I found the following in Ext.net.DirectEvent.beforerequest listener:
And according to Ext.Ajax.request docs,
jsonData : Object/String (Optional)<div class="sub-desc" style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 16px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">JSON data to use as the post. Note: This will be used instead of params for the post data. Any params will be appended to the URL.
My immediate concern is when I have specified POST as the request method, why then the data is being sent in the Url?? Why does Ext.net encodes it into jsinData making ExtJs append it into the url??
I have checked that .asmx WebService methods can pick their arguments from POST data also. So, what is the reason for forcing data to be sent through url for json requests??
Digging deep into the code, I found the following in Ext.net.DirectEvent.beforerequest listener:
if (o.cleanRequest) {
o.params = Ext.apply({}, o.extraParams || {});
for (var key in o.params) {
var ov = o.params[key];
if (typeof ov == "object") {
o.params[key] = Ext.encode(ov);
}
}
if (o.json) {
o.jsonData = o.params;
}
}
And according to Ext.Ajax.request docs,
jsonData : Object/String (Optional)<div class="sub-desc" style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 16px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">JSON data to use as the post. Note: This will be used instead of params for the post data. Any params will be appended to the URL.
My immediate concern is when I have specified POST as the request method, why then the data is being sent in the Url?? Why does Ext.net encodes it into jsinData making ExtJs append it into the url??
I have checked that .asmx WebService methods can pick their arguments from POST data also. So, what is the reason for forcing data to be sent through url for json requests??