0

I am using jsonp and everything works perfect cross domain except some functions.. like:

beforeSend:function(){
     errobj.show();
    errobj.html('<b>Loading...<\/b>');
  },

it never shows loading if i am using it cross domain (subdomains).. also some animations and show and hide things never work.

Anyone has any idea about cross domain ajax/jquery issues?

user1713941
  • 152
  • 2
  • 11

1 Answers1

1

For security reasons, browsers tend to unilaterally block any calls being made to URLs outside the domain that served the current page. Use JSONP, which can request content cross-domain is the <script> tag. Check these links too
Methods for Handling Cross-Domain Ajax Calls
JQuery ajax cross domain

[EDIT]

Also there is an issue with beforesend() in $(ajax) for datatype jsonp. Cross-domain JSONP requests do not use XMLHTTPRequest, so the event flow is different.beforesend() not firing in JSONP

Community
  • 1
  • 1
Nandakumar V
  • 3,563
  • 2
  • 22
  • 44
  • if you read my question properly.. you would know what I am asking.. jsonp is already being used by me.. i am not asking how to get or send data.. i know very well how to use jsonp – user1713941 Dec 08 '12 at 07:05
  • @user1713941 sorry, i was just posting some resources which might have discussions on cross domain issue (since you suspect its a cross domain ajax/jquery issues). – Nandakumar V Dec 08 '12 at 07:11
  • have you debugged it with firebug? any errors or warning. Also try putting some breakpoints also. – Nandakumar V Dec 08 '12 at 07:14
  • 1
    i think its the issue with `beforeSend` function. check this link [beforeSend](http://stackoverflow.com/questions/4663406/jquery-how-to-enable-beforesend-for-ajaxdatatypejsonp-is-there-a) – Nandakumar V Dec 08 '12 at 07:18
  • yes @Nandakumar V your thinking is right.. i am going to remove beforesend and try plain thing.. will let you know once tested – user1713941 Dec 08 '12 at 07:28
  • given you +1 .. will accept your answer once tested.. thank you – user1713941 Dec 08 '12 at 07:29