好吧,这很奇怪。当我尝试测试我的代码时出现以下错误。出于某种原因,我的 URL 地址显示为两次。
GET http://howtodeployit.com/howtodeployit.com/api/get_recent_posts/ 404 (Not Found)
JS:
$(document).on('pagebeforeshow', '#blogposts', function() {
//$.mobile.showPageLoadingMsg();
$.ajax({
url: "http:/howtodeployit.com/api/get_recent_posts/",
dataType: "json",
jsonpCallback: 'successCallback',
async: true,
beforeSend: function() { $.mobile.showPageLoadingMsg(true); },
complete: function() { $.mobile.hidePageLoadingMsg(); },
success:function(data){
console.log(data);
// successful request; do something with the data
$('#postlist').empty();
var html = '';
for (i=0; i<data.posts.length; i++) {
html += '<li>' + data.posts.title + '</li>';
}
$("#postlist").append(html).listview("refresh");
},
error: function (request,error) {
alert('Network error has occurred please try again!');
}
});
});