derek5. 2013-05-10 22:42 采纳率: 100%
浏览 36

JSON的jQuery Ajax xBrowser

I have some code that uses jQuery to make an AJAX call to a non-local server for 'supposed' JSON data. However, I have no way of knowing what the data yet contains, as I am receiving a bad return from the $.parseJSON(varjson) method.

The HTTP request in my web console indicates the response text is 307 characters long, so is there a way for me to simply check what's in the response?

    <script type="text/javascript">
$(document).ready(function (){
    $("#button").click(function(){                
        var url = "http://developer.pw-hq.com/api/session";

        var success = function(data){
        alert('in function');
            var html = [];
            /* parse JSON */
            //data = $.parseJSON(data);
            /* loop through array */
            alert(data);
            $.each(data, function(index, d){            
                html.push(
                          "Device Secret : ", d.deviceSecret, ", ",
                          "Name : ", d.name, ", ",
                          "ID : ", d.id, ", ",
                          "Role : ", d.role, ", ",
                          "Trust Level : ", d.trustLevel, ", ",
                          "E-Mail : ", d.email, ", ",
                          "Timezone : ", d.timezone, ", ")
            });
            alert(html);
            console.log(data);
            $("#return").html(html.join('')).css("background-color", "orange");
        };

        $.ajax({
          type: 'POST',    
          url: url,
          data:{email:"applicant@pw.me.as-a.com", password:"assessmyskillz", deviceId:""},
          dataType: "application/json",
          crossDomain: true,          
          cache:false, 
          success: success,
          error: function (xhr, ajaxOptions, thrownError) {
          alert(xhr.status);
          alert(thrownError);
          }
        });
    });
});

Feel free to attempt a solution. The credentials are legitimate. For potential work :-p

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#java#的问题,请各位专家解答!
    • ¥15 急matlab编程仿真二阶震荡系统
    • ¥20 TEC-9的数据通路实验
    • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
    • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
    • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
    • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
    • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
    • ¥30 求解达问题(有红包)
    • ¥15 请解包一个pak文件