$ .Post不包含任何回复 [英] $.Post contains no response

查看:197
本文介绍了$ .Post不包含任何回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有来自另一台处理数据的服务器的 .php 文件。该数据以表格形式列出。因此,每当我使用 $。post 使用正确的参数调用此页面时,其响应就不算什么了。我检查了我的代码,也许标题是负责它的人。我真正想要的是返回我的表格数据,以便我可以将其填充到另一页面。我的标题是这样的,标题(Content-type:application / json); 。我错过了什么?

I have a .php file from another server which processes data. This data is tabulated. So whenever I call this page using $.post with the right parameters, its response is nothing. I checked my code and maybe the header is the one responsible for it. What I want actually is to return my tabulated data so that I can populate it to another page. My header is like this, header("Content-type: application/json");. What am I missing?

$.post('http://333.333.33.33/reporting/table.php?loc_id='+locid+'&loc_type='+loctype+'',{loc_id:locid, loc_type: loctype},function(data){
    $('table#default_table').hide();
    $('div#generated_table').html(data);
});

这就是我调用$ .post的方式。

that is how I call my $.post.

推荐答案

您的朋友已成为同源策略的另一个受害者 - 幸运的是,这可以通过使用名为JSONP的方法解决。但是,这确实需要GET而不是POST请求。我自己不得不使用它,我不知道它是如何工作的,所以我问一个问题,得到了一个很好的答案!

You my friend have become yet another victim of the Same Origin Policy - luckily, this can be "worked around" by using a method called JSONP. This does, however, require a GET rather than a POST request. I myself had to use this, and I had no idea about how it worked, so I asked a question and got a wonderful answer!

这篇关于$ .Post不包含任何回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆