views:

198

answers:

1

I am having trouble figuring out a way to get some data back from a url in adobe air. It seems that there are security restrictions in air such that doing a normal callback will not work. So something like:

 $.getJSON( requestURL, 
               function(json)
         {
             $('#response').append("working");
         }
          );

Doesn't execute the callback. Is there some way to get around this? I did find some mention of this and a possible solution at http://css.dzone.com/news/jsonp-request-adobe-air but that doesn't seem to be working for me. I can run the code just fine in a normal browser but in air it fails to call either the dataFilter or the sucess method.

+1  A: 

I figured this out so I'll just post an answer. Thanks to the spaz open source twitter client from which I ripped some of this.

var xhr = $.ajax({ complete: function (xhr, rstr)
              {
               result = xhr.responseText;
               cleanresult = result.substr(result.indexOf('(') + 1, result.lastIndexOf(')') - result.indexOf('(') - 1);
               object1 = JSON.parse(cleanresult);
              },
            error: function (xhr, rstr) { },
            success: function (data) {},
            beforeSend: function(xhr) {},
            processData: true,
            url: requestURL,   
            type: "GET"}
             );

This just returns a string so then I used the json2 library to parse it into an object and that seemed to work. Seems to work across domains and everything.

stimms