【问题标题】:jQuery json call not working on mls/idx pagejQuery json 调用在 mls/idx 页面上不起作用
【发布时间】:2013-04-27 01:31:17
【问题描述】:

我的房地产网站包含来自第三方服务器的 mls/idx 数据。 jQuery 函数在我自己的站点上运行良好,但无论何时在 mls/idx 页面上,jQuery 调用都不起作用。在 idx 页面上,以下是 jQuery 库的包含方式:

....    
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=3.5.1'></script>
<script type="text/javascript">
   var jq = $.noConflict();
</script>

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js'></script></head>
....

下面是定义元素和调用 jQuery 的方式:

<select id="select_agent_id" name="select_agent_id">
    <option value="cw123">C.W.</option>
    <option value="ds123" selected="selected">D.S.</option>
    <option value="jl456">J.L.</option>
</select>


<script language="javascript" type="text/javascript">
jq(document).ready(function() {
    jq("#select_agent_id").change(function() {
        jq.getJSON("http://mysite.com/wp-content/themes/mytheme/get_agent_info.php", {"agent_id" : jq(this).val()}, function(agent,status) {
            jq("#first_name").html(agent.first_name);
            jq("#last_name").html(agent.last_name);
            jq("#agent_title").html(agent.agent_title);
            ....
        });
    });
});
</script>

有人可以帮我找出问题所在吗?第 3 方 idx 提供商根本没有帮助。非常感谢!

【问题讨论】:

标签: jquery cross-domain jsonp


【解决方案1】:

只包含

回调=?

作为 URL 中的参数。这会将调用转换为进行跨域调用所必需的 JSONP。

更多信息:http://api.jquery.com/jQuery.getJSON/

【讨论】:

  • 谢谢KingKongFrog,确实是跨域请求,所以需要jsonp。
猜你喜欢
  • 2015-02-02
  • 1970-01-01
  • 1970-01-01
  • 2016-01-03
  • 1970-01-01
  • 1970-01-01
  • 2017-12-09
  • 2015-08-05
  • 2012-06-12
相关资源
最近更新 更多