Chrome扩展程序$ .post请求回调失败

时间:2013-11-15 01:56:54

标签: jquery json google-chrome-extension

我有谷歌Chrome扩展程序。在我的Content.js中,我正在执行一个POST请求,除了在返回json数据时没有得到回调响应时,它运行正常。

这是我的电话

$.post(("http://localhost:4089/i3cloud.com/ilinklogemailnoimap.ashx?opensocial_owner_id=" + ownerId),
        '{"data":"' + dataString + '"}' ,
        function () {
            alert('response');
            },
        "json");

它调用一个ashx处理程序,该处理程序返回处理程序的以下响应。

context.Response.Write("{'user_exists' : true, 'result' : 'Success'}")

我没有得到回调......

如果响应为空,我会得到响应,并且会调用我的警报。

context.Response.Write("")

我的JSON响应格式是否正确?

我正在使用jquery-2.0.2

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我设法使用以下内容:

"[{\"user_exists\":\"true\",\"result\":\"Success\"}]"

我使用以下内容生成了json:

 JavaScriptSerializer serializer = new JavaScriptSerializer();
    responseList = new List<responseItem>();
    responseItem ri = new responseItem();
    ri.user_exists = "true";
    ri.result = "Success";
    responseList.Add(ri);
    context.Response.Write(serializer.Serialize(responseList));
相关问题