weixin_33725239 2014-09-28 10:01 采纳率: 0%
浏览 22

Ajax jsonp丢失; 错误

I am near a solution to get json data, just get the error : SyntaxError: missing ; before statement

My json data look like this :

{"custom1":"","dateOfBirth":null,"custom2":"","custom3":"","custom4":"","custom5":""}

I am using jsonp. this solved my problem with CORS (Cross-origin request blocked) In the debugger i can see the data in the NET. How close i am? Som get me the last push to resolve my problem??

<script type="text/javascript">
function getdata() {
    $.ajax({
        type: 'GET',
        url: 'http://myurl/api/getUser/22?_key=123456789',
        dataType: 'jsonp',
        //contentType: "application/jsonp",
        success: function (data) {
                              $('#badge').append(result);
        }
    });
}

  • 写回答

1条回答 默认 最新

  • weixin_33749131 2014-09-28 10:05
    关注

    You have to set your ajax response type to jsonp instead of json.

    Like

    dataType: 'jsonp'
    

    You can read more about it in jquery docs on $.ajax. Also as I can see, the result variable that you are trying to append in the success callback is not declared & inititalized anywhere in the code you have provided.

    评论

报告相同问题?