使用jQuery通过Ajax获取数据 [英] Fetching data through ajax using jQuery
本文介绍了使用jQuery通过Ajax获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在不同的服务器上有两个页面.
I have two pages in different server.
通过ajax,我想包含一些数据:这是一个示例:链接
Through ajax I would like to include some data: here is an example: link
该链接正在通过浏览器工作.
The link is working through browser.
jQuery(window).ready(function() {
getPageWithAjax("http://www.betcatcher.com/index.php?page=valuebets&nr_row=6");
function getPageWithAjax(page)
{
//alert(page)
ajaxRequest = $.ajax(
{
url: page,
cache: false,
success: function(msg){ajaxResponse(msg)},
error: function(msg){ajaxResponse('Error loading data.'+msg.status)}
});
}
function ajaxResponse(msg)
{
$("#live_bet_ajax_content").html(msg);
}
});
但是在尝试获取数据时出现错误.
But I'm getting error when I'm trying to get data.
推荐答案
我假设您从其他域调用脚本.您应该使用支持跨域调用的JSONP.阅读本文如何执行此操作.
I assume, that you call script from different domain. You should use JSONP which supports cross-domain calls. Read this article how to do this.
这篇关于使用jQuery通过Ajax获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文