The data to be transmitted asynchronously:
XML code
....
<action xsi:type= "Basic:javascript" script= "index + + 1;" />
....
Ajax Asynchronous Transfer code:
JS Code
Copy Code code as follows:
var postdata = "input=" + Escape (Inputjson) + "&script=" +escape (XML) +
"&feedgeneral=" + Escape (feedgeneral);
Xmlhttprequest.open ("POST", url,true);
Xmlhttprequest.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
Xmlhttprequest.send (PostData);
PostData in encode and unencode, eventually resulting in the background servlet to get Data + is replaced by a space, so that the script in the index = 1, changed to index = 1, which causes the background Java code in the run script appears dead loop.
Search on the Internet, found Content-type use application/x-www-form-urlencoded after:
[From http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1] wrote
Copy Code code as follows:
Control names and values are escaped. Space characters are replaced by ' + ', and then reserved characters, are as
described in [RFC1738], section 2.2:non-alphanumeric characters are replaced by '%hh ', a percent sign and two hexadecimal
Digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., '%0d%0a ').
However, using form to submit a request without a similar problem will not occur, and the form default Content-type is also application/x-www-form-urlencoded:
JS Code
Copy Code code as follows:
$ (' test '). InnerHTML = "<form target= ' _blank ' id= ' test_form ' action= './gen_feed ' method= ' post ' > '
+ "<input type= ' text ' name= ' input '/><input type= ' text ' name= ' script '/>"
+ "<input type= ' text ' name= ' feedgeneral '/><input type= ' hidden ' name= ' format ' value= '" + This.feed_type + "'
/> "
+ "<input type= ' submit ' value= ' Gen '/></form>";
var test_form = $ (' test_form ');
Test_form.elements[0].value = Inputjson;
Test_form.elements[1].value = script;
Test_form.elements[2].value = feedgeneral;
Test_form.submit ();
Still do not find out where the problem is, temporarily make a memo. For the time being, the script ' + ' is replaced with '-', index = 1; change to index-= 1; hehe, someone later saw this automatic generation of strange script, do not know how to feel, but now can only be so.