如何在javascript或jquery中从这个特定的api获得结果? [英] How do I get results from this particular api within javascript or jquery?
问题描述
您好
我需要获取此api请求的结果 http://mongol.brono.com/mongol/api.php?commandname=get_units&user=juanpablo2&pass=misoft2013&format=xml1 [ ^ 来自javascript或jquery。在C#中使用HttpWebRequest和GetResponseStream很容易。喜欢
HttpWebRequest request =(HttpWebRequest)WebRequest.Create(http://mongol.brono.com/mongol/api.php?commandname=get_units&format= xml1& user = juanpablo2& pass = misoft2013);
HttpWebResponse response =(HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
ds.ReadXml(resStream);
但我不知道如何在javascript或jquery中执行此操作。至少我没有成功。
请帮助我。在此先感谢
Hello
I need to get the results of this api request http://mongol.brono.com/mongol/api.php?commandname=get_units&user=juanpablo2&pass=misoft2013&format=xml1[^] from javascript or jquery. In C # is easy with HttpWebRequest and GetResponseStream. Like
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://mongol.brono.com/mongol/api.php?commandname=get_units&format=xml1&user=juanpablo2&pass=misoft2013");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
ds.ReadXml(resStream);
But I have no idea how to do it in javascript or jquery. At least I have not been succesfull.
Please help me. Thanks in advance
推荐答案
在Javascript中发出HTTP请求是一件非常基本的事情。这就是Ajax的基础:
http://en.wikipedia.org/ wiki / Ajax_%28programming%29 [ ^ ]。
将它与jQuery一起使用会更加方便。请参阅: https://api.jquery.com/jQuery.ajax [ ^ ]。
-SA
Making HTTP requests in Javascript is a very fundamental thing. This is what Ajax is based on:
http://en.wikipedia.org/wiki/Ajax_%28programming%29[^].
Using it with jQuery is done much more convenient. Please see: https://api.jquery.com/jQuery.ajax[^].
—SA
您可以通过REST完成: -
http://rest.elkstein.org/2008/02/using-rest-in-javascript.html [ ^ ]
You can do it by REST :-
http://rest.elkstein.org/2008/02/using-rest-in-javascript.html[^]
这篇关于如何在javascript或jquery中从这个特定的api获得结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!