It's not a cross-domain security issue, it's a JSONP issue (maybe an authentication issue). Twitter's API allows you to make GET requests which are returned as JSON with an option to specify a callback function. Afaik it doesn't support JSONP however. You can add &callback=some_function and the response will be:
some_function(true) In a cross-domain getJSON call jQuery appends the response to the document in a SCRIPT tag (no ajax involved). The problem may be that this is an API call that requires authentication. I say 'may' because it looks like you can hit the URL in the browser (try Chrome) and get the response back without setting the auth header. (try http://twitter.com/friendships/exists.json?user_a=cnn&user_b=cnni&callback=foobar) My first suggestion is create a global callback function, then append that function name to the URL (as above). On Jun 6, 1:39 pm, Aaron Gundel <aaron.gun...@gmail.com> wrote: > My guess is that you're not building an extension for twitter that > will run on their site, so you're violating the cross domain request > rule. You cannot directly request from twitter.com, you'd have to > proxy through a page on your site (some page that forwarded this > request to twitter and returned the same result) or you can use jsonp > to achieve the same effect, which is probably what you're looking for. > Hopefully this will help you. > > $(document).ready(function(){ > $.ajax( { > url: > 'http://twitter.com/friendships/exists.json?user_a='+ > usera + '&user_b=' + userb, > dataType: "jsonp", > success: function(data) > { > if(data == true) > { > var newDiv = > '<p>true</p>'; > } > > > $('#content').append(newDiv); > } > })}); > > On Sat, Jun 6, 2009 at 3:47 AM, grand_unifier<jijodasgu...@gmail.com> wrote: > > > <!-- this is the javascript json parser function --> > > > <script type="text/javascript" src="../jquery-1.2.6.min.js"> > > </script> > > > <script type="text/javascript"> > > > $(document).ready(function() > > { > > $('form#search').bind("submit", function(e) > > { > > e.preventDefault(); > > $('#content').html(''); > > > var query1 = urlencode($('input[name="user_a"]').val > > ()); //userA > > var query2 = urlencode($('input > > [name="user_b"]').val()); //userB > > > > > $.getJSON('http://twitter.com/friendships/exists.json? > > user_a='+query1+'&user_b='+query2, > > function(data) > > { > > > if(data.text == 'true') > > { > > var newDiv = '<p>true</p>'; > > } > > > $('#content').append(newDiv); > > > }); > > }); > > }); > > > function urlencode(str) { > > return escape(str).replace(/\+/g,'%2B').replace(/%20/g, > > '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40'); > > } > > }); > > > </script> > > > <!-- javascript ends here --> > > > i dont understand wats wron wth this code...could anyone plz correct > > it....plz....its very frustratin... > > any help wil be appreciated...