Javascript 使用jquery post从其他站点加载图像?
我尝试使用query从其他站点加载图像,并在div中替换它Javascript 使用jquery post从其他站点加载图像?,javascript,jquery,Javascript,Jquery,我尝试使用query从其他站点加载图像,并在div中替换它 MY HTML: <div id="img_30"></div> <div id="img_120"></div> <div id="img_day"></div> <div id="img_week"></div> <div id="img_month"></div> 因此,我的jQuery.post()应该如下所
MY HTML:
<div id="img_30"></div>
<div id="img_120"></div>
<div id="img_day"></div>
<div id="img_week"></div>
<div id="img_month"></div>
因此,我的jQuery.post()应该如下所示:
$.post( "http://www.chartty.com/investorzChart.php",
{ symbolnsources: "symbolnsources",
period: "monthly",
interval:"1",
Cycle:"MONTH1",
})
.done(function( data ) {
alert( "Data Loaded: " + data );
});
或者不是
谢谢。如果要将数据附加到url,您需要一个get请求,请在Cylcle之后,在传递的数据末尾再加上一个逗号:
$.get("http://www.chartty.com/investorzChart.php", {
symbolnsources: "symbolnsources",
period: "monthly",
interval:"1",
Cycle:"MONTH1"
}).done(function(data){
//load the data into your site unfortunately the link provided is down so I can't see the data format returned
});
这个答案假设启用了CORS。您不能进行跨源javascript请求。您必须进行JSONP调用…可能重复
$.post( "http://www.chartty.com/investorzChart.php",
{ symbolnsources: "symbolnsources",
period: "monthly",
interval:"1",
Cycle:"MONTH1",
})
.done(function( data ) {
alert( "Data Loaded: " + data );
});
$.get("http://www.chartty.com/investorzChart.php", {
symbolnsources: "symbolnsources",
period: "monthly",
interval:"1",
Cycle:"MONTH1"
}).done(function(data){
//load the data into your site unfortunately the link provided is down so I can't see the data format returned
});