开发者

Json error on Javascript

开发者 https://www.devze.com 2023-03-15 06:25 出处:网络
I need some help finding out what\'s wrong in this code: ajaxRequest.open(\"POST\", \"http://localhost:8181/add\", true)

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消