开发者

Invalid JSON with markup of my html page

I have created jquery script that was successfully run on my local machine.but when i uploaded the same script on remote server then jquery script generate error. error is "Invalid Json" and XMLHttpRequest.responseText property show my html page markup in. i have spent 3 days on internet to find the solution but i didn't. my code is here:

  <script type="text/javascript">
       var pageUrl = '<%=ResolveUrl("~/test2.aspx")开发者_Python百科%>'

        $(document).ready(function () {

            $('#<%=Button1.ClientID %>').click(function () {

                $.ajax({
                      type: "POST",
                        url: pageUrl+ "/ServerSideMethod",
                        data: "{}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            alert("1");
                        $('#myDiv').text(msg.d);
                    },
                       error: function(XMLHttpRequest, textStatus, errorThrown) { 
                    alert("Failure: " + textStatus + XMLHttpRequest.responseText ); 
                   }

                  })                     
                return false;
            });
        }); 
    </script> 

and my web method is

_

Public Shared Function ServerSideMethod() As String

    Return ("Muhammad Aurangzeb")

End Function  


The problem comes from the json generated by your "/ServerSideMethod". Check is validity with http://jsonlint.com/ to find the problem. Often an history of quotes ' versus the good use of "


If your page method is returning the page's HTML, but your local setup is working correctly, your remote server isn't configured correctly.

If it's ASP.NET 3.5, make sure the remote server's web.config matches your local one.

If it's ASP.NET 2.0, you need to also install the ASP.NET AJAX Extensions.

More information: http://encosia.com/2010/03/08/asmx-scriptservice-mistakes-installation-and-configuration/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜