ajax - JavaScript XMLHttpRequest send fails -


i try make ajax requestin chrome using following code:

var url = "http://" + document.domain + "/status_data.lua?resetsessiontimeout=false"; xmlhttp.open("get", url, true); xmlhttp.send(null); 

using wireshark see send doesn't send anything... there no get emitted. if add & @ end of url:

var url = "http://" + document.domain + "/status_data.lua?resetsessiontimeout=false&";                                                                                    ^ 

then send emit get request.

is expected?

i'm going guess couple of common errors people (and i) have made.

  1. did create instance of xmlhttp? in otherwords, have line before code above has "var xmlhttp = new xmlhttprequest();" (case sensitive)

  2. are testing through file (like c:/test.html) or on webserver (like apache or jboss)? if former, you'll cross point origin error , doing latter fix it.

  3. are sure server code not looking additional variables after resetsessiontimeout? because '&' used delimit additional variables. although i'm pretty sure unneeded end variable.

like if wanted send error string url. can resetsessiontimeout=false&errmsg=test


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -