获取JSON数据404(未找到)

时间:2013-10-21 19:52:16

标签: json jquery-mobile

好的,这很奇怪。我尝试测试代码时收到以下错误。出于某种原因,我的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!');
            }
        });
    });

1 个答案:

答案 0 :(得分:2)

你错过了第二个斜杠:"http:/howtodeployit.com/api/get_recent_posts/",你可能想要"http://howtodeployit.com/api/get_recent_posts/"