weixin_33736649 2015-09-16 12:03 采纳率: 0%
浏览 31

Ajax请求JSON数据

I try to request the following JSON Data:

 {"status":"success","id":8,"title":"Test","content":"dies ist test 12"}

With this Ajax Request:

$.ajax({
url: 'http://www.XXX.de/?apikey=XXX&search=test',
type: "GET",
dataType: 'jsonp',
success: function(data){
$('#content_test').append(data.content);
 },
 error: function(data){
 //
 }
});

It is not working. What I'm doing wrong?

  • 写回答

2条回答 默认 最新

  • 关注

    Here is an example on how to use jsonp

    $.ajax({
        url: 'http://www.XXX.de/?apikey=XXX&search=test',
        type: 'GET',        
        dataType: 'jsonp',
        jsonp: '$callback',
        success: function(data) {
            console.log(data);
            $('#content_test').append(data.content);
        },
        error: function(err) {
            console.log(err);
        }
    });
    

    Also open your development tool (Ctrl + Shift + J) and check if you have any errors in your console output.

    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程