Ajax

Oct 14, 2010 at 5:19 AM

Hi!

I must do ajax responses for XMLHttpRequests. As for start I use HttpListener example. But on client side i always get empty body of response. Please help me!

Thank you!

Coordinator
Oct 14, 2010 at 5:31 AM

Show me your code.

Oct 14, 2010 at 6:09 AM
Edited Oct 14, 2010 at 9:00 PM

As I found it was cross domain problem!

Thank you!

Closed!

Oct 14, 2010 at 6:19 AM
Edited Oct 14, 2010 at 9:06 PM

 

 

Oct 14, 2010 at 2:07 PM
Edited Oct 14, 2010 at 9:06 PM

 

 

 

Jul 25, 2011 at 9:12 AM
edward83 wrote:

As I found it was cross domain problem!

Thank you!

Closed!

Hi, how you solved it? 

Jul 28, 2011 at 1:38 PM
Edited Jul 28, 2011 at 1:51 PM

@win32nipuh for cross domain ajax you must return content of your json document within braces of callback function's name.

For example if callback function from client side has name jsonp_callback and your server's side json content in C#:

String refMyJson = LoadJsonFile();

you must return such construction:

String refResponse = "jsonp_callback(" + refMyJson + ");";

As well it will not json, it will be javascript and your return type must be js, not json;

check this question http://stackoverflow.com/questions/3935638/ajax-response-body-is-empty

and this explanation http://remysharp.com/2007/10/08/what-is-jsonp/

Good luck!:)