当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Able to receive data using $_GET but not $_POST

问题描述:

This question already has an answer here:

  • Send POST data using XMLHttpRequest

    6 answers

网友答案:

This might help:

 ajaxRequest.open("POST","dat.php", true);
 ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 ajaxRequest.send("q="+str);
网友答案:

Take a look at this page.
http://www.openjs.com/articles/ajax_xmlhttp_using_post.php

Right now, you're sending a post request with nothing in it. Appending to the url just changes the $_GET variables.

网友答案:

You are mixing POST Ajax call with GET way

When you send an AJAX call with POST, you don't have to put parameter on the URL, but you must send parameters using the .send() method.

exemple:

ajaxRequest.open("POST","dat.php",true);
ajaxRequest.send("q=" + str);

You should use a JS librairy like jQuery or other, that will make it for you, instead of re-inventing the wheel and have common problems.

分享给朋友:
您可能感兴趣的文章:
随机阅读: