I have to send the XML from the client side to the server side.
The method adopted by me was that:
First the xml is converted to string in the javascript and then post as a uri
var url = '/perl/set_zorder_xml.cgi'+'?'+xmlString+'&'+location+'&'+'nocache='+randomnumber;
xml string is the string that contains the xml in string form.
The post function looks like this:
if (window.XMLHttpRequest) {
req_anno = new XMLHttpRequest();
req_anno.open("POST", url, false);
req_anno.send();
}
The problem is that when my xml string is very large then html 414 error occurs i.e url too large. Is there any way out, Javascript and perl is used
I have to send the XML from the client side to the server side.
The method adopted by me was that:
First the xml is converted to string in the javascript and then post as a uri
var url = '/perl/set_zorder_xml.cgi'+'?'+xmlString+'&'+location+'&'+'nocache='+randomnumber;
xml string is the string that contains the xml in string form.
The post function looks like this:
if (window.XMLHttpRequest) {
req_anno = new XMLHttpRequest();
req_anno.open("POST", url, false);
req_anno.send();
}
The problem is that when my xml string is very large then html 414 error occurs i.e url too large. Is there any way out, Javascript and perl is used
Share Improve this question edited Jul 17, 2013 at 11:23 daxim 39.2k4 gold badges69 silver badges133 bronze badges asked Jul 17, 2013 at 11:22 ZeeshanZeeshan 8864 gold badges16 silver badges31 bronze badges 3- Wouldn't you normally send() the XML, and not add it to the querystring, seems like a strange thing to do, as you're making a GET request with a POST request. – adeneo Commented Jul 17, 2013 at 11:23
- I am new so might be i have made a mess can you ellobrate the procedure that can be followed since now my structure is like this – Zeeshan Commented Jul 17, 2013 at 11:26
-
if you use
jquery
, you may launch the request as a genuine POST request with theajax
methods. this basically sends content together with the url. this content corresponds to the url-parameters and their values and doesn't fall under the url length limits. – collapsar Commented Jul 17, 2013 at 11:28
1 Answer
Reset to default 4Even though you're doing a POST request, you're still sending the data in the querystring of the URL. Instead you should move the data to be sent as POST data, and remove it from the URL.
req_anno.open("POST", '/perl/set_zorder_xml.cgi', false);
req_anno.send('xml=' + encodeURIComponent(xmlString));
The XHR .send()
method accepts the string to be sent as the request body (ie POST data).