Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: AJAX postback fails

$
0
0
Re: AJAX postback fails
HTML, CSS, JavaScript, Flash
Re: AJAX postback fails
03/14/2012
12:22:38 AM
3GE00T5EC Show this entire thread in new window
Gratar Image based on email address
From:
To:
Attachments:
None

FWIW, I just added JSONP support to the server components for wwJsonService and wwAjaxMethodCallback. It'll be in the next rev and just work as long as a callback= query string parm is passed.

+++ Rick ---



Well, duh, that would explain things wouldn't it? I managed to forget all about that little detail.

I will look into adding support for JSONP.

Thanks.

AJAX calls don't work cross domain. XHR requests are restricted by browser policy to not work across domains so if your domain is not identical it won't work.

You can use JSONP to return data cross site though:

http://www.west-wind.com/weblog/posts/2007/Jul/04/JSONP-for-crosssite-Callbacks

+++ Rick ---



Trying to make what should be a straightforward AJAX call using jQuery's getJSON function. Here's a simplified version of my page code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US"> <head> <script src="/wconnect/Scripts/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { alert('json call'); $.getJSON('acewareuniversity.com/wconnect/awJSON.awp?&Host=EXT&target=:DATAPATH\zip.dbf;zipcity,zipstate;zipstate=[KS]',function (xObj) { alert('result received'); }) }) </script> </head> <body> <h1>Test of awJSON</h1> <a href='acewareuniversity.com/wconnect/awJSON.awp?&Host=EXT&target=:DATAPATH\zip.dbf;zipcity,zipstate;zipstate=[KS]'>Show JSON</a> </body> </html>

But I cannot get the callback function to execute. I can click the Show JSON link (which points to the same URL used by getJSON) and I get back the expected JSON string, so I know the server side method is working. That was further verified by activating Fiddler and running the getJSON request - the JSON string shows up in Fiddler but I never see that callback alert.

If I point the same call against my localhost app it works fine.

Would appreciate any help figuring out what could be wrong here...

--stein

FYI, those links will only work from authorized clients, so don't try to test the page from your system.






Rick Strahl
West Wind Technologies

Making waves on the Web

from Maui, Hawaii

Viewing all articles
Browse latest Browse all 10393

Trending Articles