[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-15 Thread Richard D. Worth
On Dec 15, 2007 5:32 AM, Mario Moura <[EMAIL PROTECTED]> wrote: > Hi Richard > > Thanks a lot. I will start read John Resign Book and study a lot > JavaScript. It will be time well spent. Great language. Great book. > Yes the solution is declarate the variable before but I would like this > va

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-15 Thread Mario Moura
Hi Richard Thanks a lot. I will start read John Resign Book and study a lot JavaScript. Yes the solution is declarate the variable before but I would like this varaible be global. I dont recommend use var because will turn it local So I did $(document).ready(function(){ check1 = null;

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread David Serduke
On Dec 14, 1:06 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote: > $("#target").ajaxSuccess(function(request, settings) { > if (check1 == "something") { > $(this).append(check1); > } > > }); I believe the first parameter for ajaxSuccess functions is the event. Then comes the request and

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread Richard D. Worth
Let's start with a simple example: function alertData(data) { alert(data); } //named callback function $("#mychild").ajaxForm({ success: alertData }); Notice I just give success the name of my function - alertData. No function keyword, no parens, no curly braces. I'm actually passing the fun

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread Richard D. Worth
Something like this? var check1; $("#ajax").ajaxForm({ success: function(data) { check1 = data; } }); $("#target").ajaxSuccess(function(request, settings) { if (check1 == "something") { $(this).append(check1); } }); That's untested, but should work, so hopefully it's a starting

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread Mario Moura
Almost, the problem is always "check1 is not defined" Example: function checked(check) { this.check = check } $("#ajax").ajaxForm({ success: function(data) { check1 = new checked(data) // do stuff with data;

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread Mario Moura
Wow, thanks a lot Richard I can do this with php (quite simple) but I am lost with Jquery / Javascript syntax. Could you help me? Example $("#mychild").ajaxForm({ success: function(data) { // do stuff with data; function toCheck() {

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread Richard D. Worth
You could declare a function and give it a name, instead of using an anonymous function, then pass that as the success function for each ajax call. - Richard On Dec 14, 2007 8:51 AM, Mario Moura <[EMAIL PROTECTED]> wrote: > No. > > Let me explain better. > > In your scenario you made a individua

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread Mario Moura
No. Let me explain better. In your scenario you made a individual AJAX request and into this request you create rules. But JQuery could create an universal AjaxSucess to test all data from all ajax requests. So imagine this scenario: The page have a lot of AJAX requests, something like ajaxfo

[jQuery] Re: Is it possible get the data from ajaxSuccess?

2007-12-14 Thread Giovanni Battista Lenoci
Don't know if I understood, $.ajax({"type": "POST", "url": " foo2.php", "data": data, "dataType": "json", "success": function(server_response) { switch(server_response.wich_function) { case '1': on_success_one(server_response);