开发者

Javascript jquery to contact an API

开发者 https://www.devze.com 2022-12-09 10:55 出处:网络
I\'m trying to connect to a webapi at a location that looks like this from inside my j开发者_如何学Gos jquery file.

I'm trying to connect to a webapi at a location that looks like this from inside my j开发者_如何学Gos jquery file.

example.com/?var=input

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消