javascript - XMLHttpRequest doesn't work asynchronously -
here's js
var req = new xmlhttprequest(); req.open('post','/some-location',true); req.send("a string processed server-side"); var resp = req.responsetext;
trouble is, doesn't work. whenever utilize console.log(resp)
see response, it's empty string.
but when alter sec line req.open('post','/some-location',false);
, resp
processed result. don't want set async false
, though.
is there plan javascript way see i'm doing wrong?
it not work because not ajax request. must utilize ajax. not complicated , can find instructions at
http://www.w3schools.com/ajax/default.asp.
javascript ajax post asynchronous xmlhttprequest
No comments:
Post a Comment