读书人

用js获取后盾数据并返回数据

发布时间: 2012-06-22 16:16:32 作者: rapoo

用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"}
就可以实现了

读书人网 >JavaScript

热点推荐