user3311351
user3311351

Reputation: 311

Calling web service without using a post back

I need to call a cross domain web service (.asmx) via a page within an asp.net application. The user will type in a search query in which the app will send off to the web service, then the page will be updated with the data.

My question is how might I do this without postbacks? As I am just trying to retrieve data rather than entering or manipulating it.

My attempted solutions:
1. Ajax via jquery -> issue: CORS is not supported.
2. serviceReference (for client side services calls) but this is only for a local (on domain) service
3. Lastly I am trying to use updatepanel where the value from a textbox is used in querying the web service however this is obviously forcing a partial postback, is there a way to have the update panel use a get req instead? If not, how might I go about doing this because I am stuck! Lastly would this solution be easier if an ASP MVC structure? I am learning. Thanks.

Upvotes: 1

Views: 973

Answers (1)

Stefan Steiger
Stefan Steiger

Reputation: 82196

Create an ashx handler which queries the remote service based on parameters handed by ajax.
Use an ajax-request to the ashx handler to call your proxy via jQuery AJAX.

Or just use the Yahoo YQL proxy:
Is there a free JSON proxy server which supports CORS or JSONP?

Or if the web-service supports JSONP, you can use JSONP directly.

If you need to create a proxy yourself, here is how:
http://www.codeproject.com/Articles/25218/Fast-Scalable-Streaming-AJAX-Proxy-continuously-de

Upvotes: 4

Related Questions