开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜