开发者

jQuery.post() data not "posting"

I am working on a project that requires posting JSON data to a specific URL. I am trying to use the jQuery.post() method to do this. I have two problems I can't seem to figure out.

The first problem:

jQuery.post("http://cowbell.grooveshark.com/more.php?getCommunicationToken", dataString, function(data){ alert(data) } );

Using a packet sniffer I discovered that the variable dataString was not being posted. Really no content was being posted at all.

The second problem is that the more.php script was returning the the content below in a packet:

could not parse, no method specified!

This isn't a problem at the moment; however, the success function in my jQuery.post() alerted with an empty data variable.

Here are my references:

Thanks for any help anyone has!


You can't do ajax-requests to other domains due to the same origin policy, quote from the jQuery API page you linked:

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.


Does the domain you are posting to have a web service that it can expose to you? That will help you in posting the data correctly...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜