javascript - XMLHTTPRequest is not working with IIS integrated Mode -
while running code under classic mode works fine.....but fails when runnnig under integrated mode.
here code: -
function callajax(method, request, callback) { http = newhttp(); http.open('post', url, true); setupheaders(http, method); http.onreadystatechange = function () { http_onreadystatechange(http, callback); } http.send(json.stringify(request)); return request.id; } function newhttp() { if (typeof (window) != 'undefined' && window.xmlhttprequest) return new xmlhttprequest(); /* ie7, safari 1.2, mozilla 1.0/firefox, , netscape 7 */ else return new activexobject('microsoft.xmlhttp'); /* wsh , ie 5 ie 6 */ } function http_onreadystatechange(sender, callback) { if (sender.readystate == /* complete */4) { var response = sender.status == 200 ? json.parse(sender.responsetext) : {}; response.xmlhttp = sender; callback(response); } if (sender.readystate == 2 || sender.readystate == 3) { } } function setupheaders(http, method) { http.setrequestheader('content-type', 'text/plain; charset=utf-8'); http.setrequestheader('x-json-rpc', method); } it returns following response when running under classic mode: -
"{"id":0,"result":{"serverinfo":{"totalcount":2,"servicename":"fluorinefx.pageableresult","version":1,"cursor":1,"id":null,"columnnames":["applicationid","applicationparentid","parentapp","childapp"],"initialdata":[[1158,1153,"apps","app_application1"],[3159,3161,"databases","db_database1"]]}}}" whereas, returns following when running under integrated mode : -
" <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> </title></head> <body> <form method="post" action="xxxxx...." id="form1"> <div class="aspnethidden"> <input type="hidden" name="__viewstate" id="__viewstate" value="/wexxxxlte2mty2odcymjlkzlguneiyazaly9gctafyavvtqg2payfqxe2oab+1pjxt" /> </div> <div> </div> </form> </body> </html> " due above response fails inside http_onreadystatechange() method in line: -
var response = sender.status == 200 ? json.parse(sender.responsetext) : {}; my issue why returns weird response when running under integrated mode?
Comments
Post a Comment