仅用于测试目的我想在我的AJAX调用中传递一个内联json文件,似乎参数URL必须是一个URL,有没有办法解决这个问题,所以我可以通过调用解析一个内联json文件,当前代码如下,但不起作用:
var jsonfile =[
{
"id" : "look1",
"image" : "http://images.domain.com/img.jpg",
"headline" : "UN DÍA EN MÓNACO"
}
,
{
"id" : "look2",
"image" : "http://images.domain.com/img.jpg",
"headline" : "UN DÍA EN MÓNACO"
},
.......
$.ajax({
url: jsonfile,
data: "nocache=" + Math.random(),
type: "GET",
cache : false,
contentType: "application/json",
dataType: "json",
success: function(source){
data = source;
console.log(data);
},
error: function(data){
alert("Failed to load content");
}
});