简体   繁体   English

jQuery.post()数据没有“发布”

[英]jQuery.post() data not “posting”

I am working on a project that requires posting JSON data to a specific URL. 我正在开发一个需要将JSON数据发布到特定URL的项目。 I am trying to use the jQuery.post() method to do this. 我试图使用jQuery.post()方法来做到这一点。 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. 使用数据包嗅探器我发现变量dataString没有被发布。 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: 第二个问题是more.php脚本在数据包中返回以下内容:

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. 但是,我的jQuery.post()中的success函数用空数据变量发出警告。

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: 由于相同的源策略 ,您不能对其他域执行ajax请求,引用您链接的jQuery API页面:

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy ; 由于浏览器安全限制,大多数“Ajax”请求都遵循相同的原始策略 ; 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? 您要发布的域名是否具有可向您公开的Web服务? That will help you in posting the data correctly... 这将帮助您正确发布数据...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM