jQuery Ajax返回302错误

I know the error 302 is because i'm getting redirected...

Here's my call in jquery :

    $.ajax({
                    type: 'POST',
                    url: 'https://url/WebServices/SearchDocuments',
                    data:"{search: " + e.target.value + " }",

                    dataType: "JSON",


                    success: function(data) {
                        GetDocumentSuccess(data[0]);
                    }
                });

I see that i'm being logged out of the webService in a way.

But when i'm using this :

  var request = WebRequest.Create(url);
        request.Method = "POST";

        ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

        using (var s = request.GetRequestStream())
        {
            using (var sw = new StreamWriter(s))
            {
                sw.Write(true); // Write anything. If the post is empty, the distant server throws an error.
            }
        }

it's working, i thinks the problem come from not having this:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

, when i call it directly from jquery

Is this the problem ?

And

Someone know how to make it work with using jquery ajax ?

查看全部
weixin_33712987
weixin_33712987
2012/06/13 20:26
  • net
  • ajax
  • jquery
  • web-services
  • 点赞
  • 收藏
  • 回答
    私信

0个回复