POST from XMLHttp with parameters

后端 未结 1 2008
南笙
南笙 2020-12-10 13:32

I\'m trying to post data to a PHP page and check the response. Here is an example. What is wrong with this code?

index.html


         


        
相关标签:
1条回答
  • 2020-12-10 14:19

    I figured it out. I needed to set the request header.

    xmlhttp.open("POST", "ajax.php", true);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send("foo=" + foo + "&bar=" + bar);
    

    source1

    source2

    0 讨论(0)
提交回复
热议问题