troubleshooting Question

Help with JQuery .ajax() post

Avatar of Geoff Sutton
Geoff SuttonFlag for Canada asked on
AJAXjQuery
3 Comments1 Solution521 ViewsLast Modified:
Hey experts,

I'm attempting to make a jquery post to a page, and I seem to be getting nowhere with it.  I can't even find error messages or indicators of where I am going wrong.  I have been given a URL for using JQUery with ASP.NET webmethods, but am needing help with the JQuery itself, which I am unfamiliar with.

Please see the code below, thanks.

Geoff
$.ajax(
        {
            type: "GET",
            url: "ChangeCodeAssignment2.aspx/GetNextRow", //Ajax file

            beforeSend:
            function(XMLHttpRequest) {
                //alert(this); // the options for this ajax request
            },

            complete:
function(XMLHttpRequest, textStatus) {
    alert(textStatus); // the options for this ajax request
    row = 0;
},

            data: { r: row },  // create an object will all values
            //function that is called when server returns a value.
            success: function(data) {
                alert(data.returnValue);
                row = 0;
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                // typically only one of textStatus or errorThrown 
                // will have info

                alert("test2");
                alert("test1");
                row = 0;
            },
            //How you want the data formated when it is returned from the server.
            datatype: "json"
        }
        )


WEBMETHOD:
    [WebMethod]
    public static string GetNextRow(string r)
    {
        return "something " + r;
    }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros