or integrate a callback into your helper function:
function getDataJSON(psType,psParams,*callback*)
{
   var sParms="someurl"+psType+psParams

   var jsonRequest = new Request.JSON(
   {
       url: sParms,
       noCache: true,
       async: false,
       onSuccess: function(searchResults){
           *callback(searchResults);*
       },
       onFailure: function(errfail) {
           alert(errfail);
           return "";
       }
   }).send();

}

*getDataJSON('x', 'y', function(obj){*
* **//do stuff with the json object*
*});*

but making standalone functions like this is not a good practice. you should
be writing classes.

On Fri, Aug 7, 2009 at 12:00 PM, Gafa <[email protected]> wrote:

>
> How do I return the onsuccess resonsetext back to the function?
>
> getDataJSON always returns undefined.
>
> function getDataJSON(psType,psParams)
> {
>    var sParms="someurl"+psType+psParams
>
>    var jsonRequest = new Request.JSON(
>    {
>        url: sParms,
>        noCache: true,
>        async: false,
>        onSuccess: function(searchResults){
>            return searchResults;
>        },
>        onFailure: function(errfail) {
>            alert(errfail);
>            return "";
>        }
>    }).send();
>
> }
>
> thanks for any help
>

Reply via email to