Hi. I was trying to cull out just the pertinent code, so that's why the calling method, etc. seems truncated. Alas (and I wish I could) I can't post the whole thing, which I know would be more useful.
All of the methods are part of jDemon. You're right, I don't know what "this" means. I was modeling that bit after some other code that I'm integrating with. As I mentioned, I'm dealing with a lot of new material. I'll try pulling the code out into stand-alone functions and see what happens. Thanks. On 9/19/07, Michael Geary <[EMAIL PROTECTED]> wrote: > > I'll bet "this" is not what you expect. What is all the "this" usage for? It > doesn't look like you are creating an object, or are > you? I don't see the calling code - do you call "new jDemon" or just > "jDemon()"? > > login, getAllCustomers, and getAllCustomersSuccess are methods of... what? > > For example: > > success: this.getAllCustomers > > When getAllCustomers() gets called, it won't be called as a method of that > particular "this" object > > Can you write the code without all the "this" stuff? (Use "this" inside the > .each callback, of course, I'm talking about the other > "this" methods.) It may be a lot easier to get it working that way. > > Do you have a link to a test page? > > -Mike > > > From: Lee Hinde > > > > 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); > > > > } > > > >