# Other Languages > jQuery >  jQuery function return value

## *PsyKE1*

I am very new to this, I made this function:


```
function getID(user){
    $.getJSON('https://twitter.com/users/'+user+'.json?callback=?',
    function(data)
    {
        $('#userid').html(data.id_str);
    });
}
```

Works well, but I want that instead of modifying the value of #userid I return a value, I tried this:


```
function getID(user){
    $.getJSON('https://twitter.com/users/'+user+'.json?callback=?',
    function(data)
    {
        return data.id_str;
    });
}
```

But it makes me return to the function within which it is, not getID.
Solutions?

Thanks!

----------


## SambaNeko

getJSON() is an asynchronous method, which I don't think can be used in that way.  But getJSON() is essentially just a wrapper for jQuery's more generic ajax() method, which allows you to set its async property (it notes that JSONP cannot support synchronous operation, but it doesn't look like you need that).  From there, you could get the jqXHR object that is returned by ajax() and parse that for your result.

----------


## szlamany

Now - I'm curious - why are you calling a twitter service like that?

Would they want to know you are doing that??

----------


## *PsyKE1*

> getJSON() is an asynchronous method, which I don't think can be used in that way. But getJSON() is essentially just a wrapper for jQuery's more generic ajax() method, which allows you to set its async property (it notes that JSONP cannot support synchronous operation, but it doesn't look like you need that). From there, you could get the jqXHR object that is returned by ajax() and parse that for your result.


Ok, thanks, I'll investigate.  :Smilie: 




> Now - I'm curious - why are you calling a twitter service like that?
> 
> Would they want to know you are doing that??


I just get the id of a twitter user.  :Smilie: 

Thanks! :P

----------


## penagate

You might be interested in the Twitter API.

----------

