简体   繁体   中英

JSON GET returns HTML when called from code/console but returns JSON object when called from web address

I am trying to run this code:

$(document).ready(function () {
    $.ajax({
        url: 'http://foodfetch.us/OrderApi/locations',
        type: 'GET',
        success: function(data){
            alert(data);
            //do work here
        }
    });
});

For some reason, the AJAX call returns HTML source code, not the JSON object that it should be returning. If you copy the URL into any web browser, the JSON object shows up in plain text.

Can anyone explain what silly thing am I doing wrong here?

正如Patrick Evans在评论中指出的那样,代码中的URL链接到带有嵌入式框架的页面,我能够通过使用框架链接到的URL来使代码正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM