使用JSONP:AJAX打印JSON响应

时间:2017-07-18 04:11:06

标签: jquery html json ajax jsonp

我正在尝试从ajax调用到URL打印JSON响应。 JSON没有打印。

但是,当我使用chrome调试器进行调试时,我可以看到json正在预览中填充

http://localhost:17770/api/v1/Profile?callback=jQuery112402874304526465612_1500350361459&_=1500350361461

  

[{userID:" bravo1234",userName:" bravo",...},{userID:" lima1234",   userName:" lima",...},...] 0:{userID:" bravo1234",userName:" bravo",...}   1:{userID:" lima1234",userName:" lima",...} 2:{userID:   " foxtrot1234",userName:" foxtrot",...} 3:{userID:" julie1234",   userName:" julie",...} 4:{userID:" tango1234",userName:" tango",...} 5   :{userID:" julie1234",userName:" julie",...} 6:{userID:   " charlie1234",userName:" charlie",...} 7:{userID:" phani1234",   userName:" phani",...} 8:{userID:" newUser1234",userName:   " newUser",...} 9:{userID:" dhanilan1234",userName:" dhanilan",...} 10:   {userID:" user1234",userName:" string",...} 11:{userID:   " adminuser1234",userName:" admin",...} 12:{userID:" shreyas1234",   userName:" shreyas",...} 13:{userID:" newuser12345",userName:   " NEWUSER",...}

$("#button_1").click(function(e) {
        e.preventDefault();
        $.ajax({
            type: "GET",
            url: "http://localhost:17770/api/v1/Profile",
            contentType: "application/json",
            dataType: 'jsonp',
                async: false,
                success: function(result){
                    debugger;
                    alert('hi');
                    $("#divhtml").html(result);
                console.log(result)
        }
        });
        });

我发现函数成功没有被调用。这种行为背后可能是什么原因。

我在stackoverflow中看到了很多关于JSONP的问题,但到目前为止还没有解决这个问题。

0 个答案:

没有答案