PDA

View Full Version : Query string problem with XMLHttpRequest () object in sencha touch



Sameer Khan
10 Jan 2012, 1:22 AM
Hi, I have to send huge amount of data to .net server...So i created xml string and added as parameter to url and i was called send(null); using xmlhttprequest() object...But here problem in .net web.config file maxQueryStringLength is "2097151"..so i cann't post more than these characters...But here in my querystring i have morethan this size...

How to solve this problem...plz help me...

AndreaCammarata
10 Jan 2012, 2:21 AM
Why don't you send it using POST action instead of GET?

Hope this helps

Sameer Khan
10 Jan 2012, 5:32 AM
var params="userId=patty";
xmlhttp.open('POST', 'http://localhost:4770/SERVICE-HANDLERS/ClientList.ashx', true);
//Headers to xmlhttprequest object
xmlhttp.setRequestHeader('Origin', 'http://localhost:4770');
xmlhttp.setRequestHeader('Access-Control-Request-Method','POST');
xmlhttp.setRequestHeader('Access-Control-Request-Headers','http://localhost:4770');
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.setRequestHeader("Cache-Control", "no-cache");
xmlhttp.withCredentials="true";

xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status==200){
alert("URL Exists!");
}
else if (xmlhttp.status==404){
alert("URL doesn't exist!");
}
else{
alert("Status is "+xmlhttp.status);
}
}
}
xmlhttp.send(params);


I have written like this...Can u plz let me know where i am doing wrong ?


But if i did like this control goes to webservice call, then it's working fine...

xmlhttp.open('POST', 'http://localhost:4770/SERVICE-HANDLERS/ClientList.ashx?userId=patty', true);

But i want to execute above one...bcz data will go inside of request body...

AndreaCammarata
10 Jan 2012, 5:43 AM
Sorry, but why don't you use a simple Ext.Ajax.request?



Ext.Ajax.request({
url: 'http://localhost:4770/SERVICE-HANDLERS/ClientList.ashx',
method: 'POST',
params: {
'userId': 'patty'
},
scope: this,
success: <YOUR_SUCESS_FN>,
failure: <YOUR_FAILURE_FN>
});

Sameer Khan
10 Jan 2012, 5:46 AM
Bcz It won't support cross platform communication , i already tried with that...so i have chosen to work with XmlHttpRequest() object to send huge data from sqlitedb to .Net server in the form of xml string...

But here also i am facing some issue...

AndreaCammarata
10 Jan 2012, 5:56 AM
So I assume your web application in running on localhost:80 ad you are trying to get your data from localhost:4770. Am I correct?

If for some reason you have to do that, until you don't move your backend on a production host, I suggest you to browse your app using the file:/// protocol instead of http://localhost.
So, just to be clear, double click on your index.html and try to make the request from the page on that url.

Sameer Khan
11 Jan 2012, 1:51 AM
Hi, what ever you said correct....And one more question is :

If i use xmhttprequest() object in sencha touch application, finally if i upload .apk file of my sencha touch application to android device and do upload then, XmlHttpRequest() object can perform communication with cross domain (i mean with .net application)