如何从Javascript或PHP访问Web服务?

编程入门 行业动态 更新时间:2024-10-24 14:17:05
本文介绍了如何从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服务?

本文发布于:2023-11-08 14:15:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569602.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Javascript   PHP   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!