Post data using $.post fails with empty data
I want to send some data using jQuery
var uri = "some url";
$.post(uri,
{ message: "test"},
{"fo开发者_如何学编程rmat" : "json"},
'html');
return false;
When the php script gets the request the message field is empty. Why?
Edit: I use zend framework to read the post data
$this->getRequest ()->getPost ( 'message' );
The js code from above workes on localhost but on the server message is empty. I check with isPost()
which says that there is no post.
You are passing two objects to $.post
. There's no reason to do this. I think you just want this:
$.post(uri,
{ message: "test"},
'html');
The server will understand the format of the posted data.
精彩评论