需要打印一个帖子请求的响应

时间:2015-04-06 10:42:55

标签: javascript ajax json post request

这是我的代码,我无法打印我要求的帖子请求的响应。我可以在控制台中看到响应,但它没有打印出来。我不知道该怎么做。

 var circleUrl ="..........my service.................";
    var circleName;
    var circleCode;
    var circleList='';

    var circleData;             
    $.ajax({
            url: circleUrl,
            type: 'POST',
            async: false,
            beforeSend: function (xhr) {
                xhr.setRequestHeader('AUTHUSER', 'dshfgsjhgdksaj');
                xhr.setRequestHeader("Content-Type","application/json");
                xhr.setRequestHeader("Accept","application/json");
            },
            data : JSON.stringify({product:"abc", flag:"S"}),
            success: function(x) {
            try {
            if(x.statusCode=="000" && x.businessOutput.responseMsg=="SUCCESS") { 
            alert(x.businessOutput.webserviceResponse.circleData);
            temp = x.businessOutput.responseCode;   
            circleData= x.businessOutput.webserviceResponse.circleData;
            $.each(circleData, function(i, item) {

                    circleName = item.name;
                    alert(circleName);
                    circleCode = item.code;
                    circleList = circleList + "<li><a onclick='selectCircle(this);' href='javascript:void(0);' circle='"+circleName+"' circleId='"+circleCode+"'> &rsaquo;"+circleName+ "<span>&nbsp;</span></a></li>";
                        });
                } 
                }catch(err) {
                    console.log('error occur  :: '+err);
                }
            },
            error: function() {     }
        }); 

    document.getElementById("circlelist").innerHTML = "<div class='layout'><h1 class='head1 padding_right_5'><span><em class='service_white'> </em><strong class='arrow-right'></strong></span><strong>select circle</strong></h1><div class='layout shadow_01'><ul class='balanceInfo summaryTxt'><li class='box_shadow_none'>Select circle of your choice</li></ul><ul class='listBox'>"+circleList+"</ul><ul class='balanceInfo summaryTxt'><li class='align_center border_bottom_none'><a class='grey_btn margin_none width60' onclick='history.go(-1);return false;' href=''>back</a></li></ul></div></div></div>";
    }

0 个答案:

没有答案