On 9/19/07, Lee Hinde <[EMAIL PROTECTED]> wrote: > Hi; > > I am trying to nest an ajax call as part of the success callback to an > ajax call. Specifically, after a successful log in, I'd like to > populate some data. > > I'm stepping into a lot of new ground, for me, so it's hard to figure > out why something isn't working. > > The login works fine. And the first callback is run, using Firebug, I > can tell that the 2nd ajax call is returning the data I expect. But > the success callback for the 2nd ajax use isn't firing. I'd be > grateful for any assistance. > > Thanks. > > > //jDemon was a typo that seemed appropriate, so it stuck > function jDemon() { > > //This works > this.login = function () { > var vusername = $("#name").val(); > var vpassword = $("#password").val(); > $.ajax({ > type:"GET", > url:"dax/login", > data: "username="+vusername+"&password="+vpassword, > success: this.getAllCustomers, > error: this.loginResponseError > } > ); > }; > > //This works > this.getAllCustomers = function (data){ > this.sessionId = $("sessionId",data).text(); > postDebug(this.sessionId); > > $.ajax({ > type:"GET", > url:"dax/allrecords", > data: "sessionid="+this.sessionId+"&tableid=1", > success: this.getAllCustomersSuccess, > error: this.loginResponseError > }); > > }; > //this never runs, although I can tell that data has come > back from the server > this.getAllCustomersSuccess = function(data){ > postDebug("getallcustomer"); > > var textToDisplay = ""; > var len=$("row",data).length; > $("row",data).each(function(i){ > > $("field",data).each(function(i){ > textToDisplay =+ $(this).attr("id"); > textToDisplay =+ $(this).text(); > > }) //each field > > } )//each row > $("#debug").text(textToDisplay); > > }; > > ;} > > //debug is a console I setup in the page. > function postDebug(textToPost){ > var hold = $("#debug").text(); > $("#debug").text(hold+"\n"+textToPost); > > } >
I found one problem with how I was referencing the variable sessionId. I broke out the 2nd call "getAllCustomers" to a link and, with the fixed variable, it works fine. But it still doesn't work when called in a nested fashion.