日期:2014-05-16  浏览次数:20305 次

用js获取后台数据,并返回数据
我自己写的html码如下:
 <img id="BTImg" src="" width="623px" height="420px" style="z-index:1; position:absolute; margin:1px 0 0 0px; ">


JS代码:var GetBTImg = function(){
  $.ajax({
  url:'http://news.guet.cn/bcapi.asmx/next',
  type: 'POST',
  dataType: 'json',
contentType: "application/json; charset=utf-8",
data: "",
  error: function(json){
   
  },
  success: function(json){
var jsonData = eval('('+json+')');
 
$('#BTImg').attr('src',jsonData.str);


}
  });
};


后台数据:<string xmlns="http://tempuri.org/">
{"str":"http://news.guet.edu.cn/BeautyAPI/image/15550.jpg"}
</string>

------解决方案--------------------
直接返回{"str":"http://news.guet.edu.cn/BeautyAPI/image/15550.jpg"}
就可以实现了