Json error on Javascript
I need some help finding out what's wrong in this code:
ajaxRequest.open("POST", "http://localhost:8181/add", true)
ajaxRequest.setRequestHea开发者_如何学JAVAder("Content-type","application/x-www-form-urlencoded");
ajaxRequest.send(data);
I'm trying to send data to the server using POST, and ajaxRequest is an ajaxRequestElement()
.
The problem is when I open the page, the console provided by Chrome to detect Javascript errors says POST http://localhost:8181/add undefined (undefined)
.
I know the URL is correct and the page receiving the data is ok too, I tried this before in PHP and works fine, so I don't understand what's happening.
It could be that you are posting to http://localhost/add instead of http://localhost:8181/add. Could you simply use 'add' as the url to post your ajax request to?
精彩评论