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 > varaible be global. > I don't think you really want a global variable here. In fact, there a very few cases (in javascript) where you actually (should) want a global variable. > > I dont recommend use var because will turn it local I recommend using var. Yes, it will turn the variable local, but that has a different meaning in javascript than other languages. Variables in javascript have function-scope, not block-scope. This means you can do var check1; at the top of your $(document).ready(function(){, and everything defined in the same function will have access to it. To get any deeper, we have to talk about closures and I'll leave that to you and John's book. For the problem you have now, you want check1.check. Notice in your checked function you're defining a member/attribute/property called check, and setting its value to check (passed in param): this.check = check When you have a checked object then (like check1), as you do later, just use dot notation to access that member: alert(check1.check); - Richard > > So I did > > $(document).ready(function(){ > check1 = null; > function checked(check) { > this.check = check > } > > $("#ajax").ajaxForm({ > success: > function(data) { > check1 = new checked(data) > // do stuff with data; > } > }); > > $("#target").ajaxSuccess(function(request, settings){ > $(function() { > alert(check1); > }) > }); > > .... > > And it is working!! So we can test response of any ajax response. > > But isnt already. When I dedug I can see the value into check1 but when > the alert run print [object Object] > > So the result is into this object "check1". How can I access the value of > an object in Javascript? > > Thanks for your help, And David thanks too, I am trying test all ajax > response no matter where they came from. > > Regards > > Mario Moura > > 2007/12/15, David Serduke <[EMAIL PROTECTED] >: > > > > > 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 settings. So iirc that would be: > > > > $("#target").ajaxSuccess(function(e, request, settings) { > > if (request.responseText == "success") { > > alert("Got a successful response"); > > } > > } > > > > Also untested. :) > > > > David > > > > > > > -- > Mário Alberto Chaves Moura > [EMAIL PROTECTED] > 31-3264-6203 > 31-9157-6000 >