How can i change the network call to sync? There is others consequences of
this change?

When you say: "So, all the work you want to do, must be done inside your
callback
function..."
I cant do that. I cant call any function from the inside of my callback
function. Doesnt work!
Like this:

jQuery.ajax({
  type: "get",
  url: url,
  data: params,
  dataType: "text",
  success: function(response) {
     this.myfunction();
   }
});


2008/11/18 Fernando Takai <[EMAIL PROTECTED]>

>
> Douglas,
>
> That's because success function is an async callback -- it runs just
> after the network call.
> When you use a callback you don't have access to the this pointer, since
> you are not inside your own object.
>
> It works like this
>
> aux = 0
> network call (after this call returns, i will call your callback)
> displayMessage
> network call returned, displayMessage
>
> So, all the work you want to do, must be done inside your callback
> function - or, change the async to sync.
>
> Cheers.
>
> On 11/18/08 5:22 PM, Douglas Nogueira wrote:
> > I have this:
> >
> > aux=0;
> >
> > jQuery.ajax({
> > type: "get",
> > url: url,
> > data: params,
> > dataType: "text",
> > error: function(msg) {
> > alert("problem");
> > },
> > success: function(response) {
> > if(response)
> > if(response==1){
> > aux=response;
> >                           displayMessage(aux); /_(1)_/
> >                      }
> >           }
> >  });
> >
> > displayMessage(aux); _/(2)/_
> >
> >
> > When i do the first displayMessage(aux) he shows 1, but when i do the
> > second he shows 0.
> > And i cant call any function inside of my sucess function...
> > What can i do to set the aux=1 if the response=1??
> >
> > -----
> > Doug
> >
> > >
>
> --
> Fernando "Takai"
> http://flickr.com/photos/supeertakai
> http://fernandotakai.jaiku.com
>
> Get Ubiquity: https://wiki.mozilla.org/Labs/Ubiquity/
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to