从PHP调用HTML控件,从HTML控件调用Web服务 [英] Call HTML control from PHP, call a webservice from HTML control

查看:73
本文介绍了从PHP调用HTML控件,从HTML控件调用Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个想法是

不管后端是什么
此HTML控件应可与任何应用程序配合使用
无论服务器代码是使用PHP,C#还是Ruby完成的
考虑一个样本控件
将用于在个人资料页面上显示以下信息
1.登录用户的照片
2.他/她的名字
假设我们只需要在此控件上显示这两件事
并且此控件应该是可重用的
也就是说,我应该能够将此HTML控件与以PHP,C#或Ruby编写的应用程序一起使用
此控件将接受照片URL并显示照片
它还将接受用户名的字符串并显示名称

the idea is

no matter what the back-end is
this HTML control should work with any application
no matter if the server code is done using PHP, C# or Ruby
consider a sample control
which will be used to show following information on a profile page
1. Logged in user''s Photo
2. His/her Name
Assume we need to show only these 2 things on this control
and this control should be reusable
i.e. I should be able to use this HTML control with an application written in PHP, C# or Ruby
This control will accept the Photo URL and show the photo
also it will accept the string for user name and will display the name

推荐答案

1)否.PHP在服务器端起作用,HTML控件仅在客户端存在边.此外,HTML控件不是方法,函数,过程,运算符或属性,也不是可调用的对象. 通话"的概念不适用.

2)您可以按照通常生成HTTP请求的相同方式,将HTTP请求发送到Web服务或从客户端大小调用Web方法:使用一些URI作为其href属性值的锚点(一个简单的例子), Web表单或Ajax调用.同样,您不必致电服务"(请参见上文).您需要在相应的HTML章节中阅读每种方法,阅读有关Ajax的知识,阅读有关Web服务和Web方法的知识;但首先,关于HTTP的工作原理.



免责声明:此答案基于问题的第1版.

—SA
1) No. PHP works on the server side, and HTML control exists only on the client side. Besides, HTML control is not a method, function, procedure, operator or property, not a callable object. The notion of "call" is not applicable.

2) You can send a HTTP request to a Web service or call a Web method from the client size the same way you normally generate HTTP request: an anchor with some URI as a value of its href attribite (a trivial case), a Web form or an Ajax call. Again, you don''t "call a service" (please see above). You need to read on each of these method in corresponding HTML chapters, read about Ajax, read on Web services and Web method; but first of all, on how HTTP works.



Disclaimer: this answer was based on v.1 of the question.

—SA


这篇关于从PHP调用HTML控件,从HTML控件调用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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