Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery post从其他站点加载图像?_Javascript_Jquery - Fatal编程技术网

Javascript 使用jquery post从其他站点加载图像?

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()应该如下所

我尝试使用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()应该如下所示:

$.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
});