如何从Javascript或PHP访问Web服务? [英] How to access web service from Javascript or PHP?

查看:129
本文介绍了如何从Javascript或PHP访问Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要从我的网络应用程序中的此处访问网络服务。当用户选择一个物种名称时,服务将通知该名称是否有效,作者和姓名的年份等。

I want to access a web service from here in my web application. When the user chooses a species name, the service will inform if the name is valid, the author and year of the name, etc.

首先我想到使用Javascript,因为信息来自用户。然后我看到跨网域限制,因此我想知道什么是最好的解决方法这里。根据此建议,我应该使用服务器端的解决方法。但在这种情况下,只是使用 php curl 功能?

First I thought of using Javascript, since the information comes from the user. Then I saw cross-domain restrictions, so I wonder what is the best workaround here. According to this suggestion, I should be using a server-side workaround. But in that case, wouldn't it be easier to just use php curl functions?

推荐答案

是的。

如果您已经使用PHP,那么cURL是通常的HTTP客户端库。

If you are using PHP already, than cURL is the usual HTTP client library.

也就是说,在您的服务器上使用PHP / cURL 跨源JS问题的服务器端解决方法,而不是使用解决方法的替代方法。

That said, using PHP/cURL on your server is the server side workaround to cross-origin JS issues, not an alternative to using a workaround.

这篇关于如何从Javascript或PHP访问Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆