0
請幫助我,我不能從我的主頁中獲取數據 我的AJAX請求:在我的主頁我如何請求從我的主頁訪問我的json.json數據?
$.ajax({
url:"http://example.com/json.json?jsoncallback=?",
type:"GET",
dataType:"jsonp",
beforeSend:function(){
console.log("before send");
},
success:function(data,status){
console.log("success");
}
});
而且json.json文件
> { "firstName": "John", "lastName": "Smith", "isAlive": true,
> "age": 25, "address": {
> "streetAddress": "21 2nd Street",
> "city": "New York",
> "state": "NY",
> "postalCode": "10021-3100" }, "phoneNumbers": [
> {
> "type": "home",
> "number": "212 555-1234"
> },
> {
> "type": "office",
> "number": "646 555-4567"
> },
> {
> "type": "mobile",
> "number": "123 456-7890"
> } ], "children": [], "spouse": null }
請建議我通過谷歌和搜索嘗試了很多這裏但不明白