views:

43

answers:

2

I'm trying to connect to a webapi at a location that looks like this from inside my js jquery file.

example.com/?var=input

Is there a simpler way to do it than an ajax call?

+1  A: 

I would use AJAX for this, but I guess you could open a hidden IFRAME with the URL set to the page you want to connect to (not sure why you would do this though!).

Maybe use a JavaScript library like JQuery to make life easier?

If the data you're trying to access is returned as JSON then you can get around the browser security problems.

Here is a JQuery example where a request is made to Flickr.com from JQuery.com:

docs.jquery.com/Ajax/jQuery.getJSON

Rew
+1  A: 

You may be run into cross domain issues if you do it with an ajax call. Call the web-api from serverside, it would be the most appropriate way.

jerjer
This page explains it quite well: http://developer.yahoo.com/javascript/howto-proxy.html
Rew