-2

What am I doing wrong? Following does not upate my json object:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

function getJson() {
    $.getJSON("http://laptop/EstimatorWeb/GetConfig.ashx", function (da) {
        json = da;
        //document.getElementById("resDiv").innerText=da;
    }).success(function () {
        alert("second success");
    }).error(function () {
        alert("error");
    });

I can see my web services returning a JSON object in FIddler. It is just this last piece that is not updating the object. I do not receive any alert either for success or for error.

4

1 回答 1

0

您需要使用 .done() 和 .fail(),.success() 和 .error()在 v1.8 小提琴示例中已弃用

$.getJSON("http://laptop/EstimatorWeb/GetConfig.ashx", function(json){
        $("#resDiv").text(json);  
     }).done(function(data){
         alert('second done' + data.Host);
     }).fail(function(e){
         alert('fail');
     });

您只需要将 json 转换为字符串

于 2013-10-17T03:33:57.010 回答