我可以从外部PHP文件调用javascript函数 [英] Can I call javascript function from external PHP file

查看:100
本文介绍了我可以从外部PHP文件调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



请帮助我..

我创建了动态网站。我已将Php文件包含到包含javascript和jquery函数的多个页面中。这是正确的方法吗?它会在我的网站上造成任何问题吗。



请帮忙。



提前致谢。



我尝试了什么:



我已将外部PHP文件添加到所有包含javascript和jquery函数的页面。它正在正常工作。

Hello,

Please help me..
I have created dynamic website. I have included Php file to multiple pages which contain javascript and jquery function. Is it a right way?? Will it create any problem in my website.

Please help.

Thanks in advance.

What I have tried:

I have added External PHP file to all pages which contain javascript and jquery Function. and it is working properly.

推荐答案

这个问题的解决方案是重新编写一个html网页,该页面具有内联javascript函数和特定的php脚本所以你执行php脚本时调用的javascript函数将在php-script中的任何函数之前被调用。这个javascript函数计算的返回值很容易通过使用AJAX请求传递给php-script中的一个或多个函数,并且你不再需要在执行php脚本时调用javascript函数。



不幸的是,除了Microsoft ASP.NET之外,现有的用于创建Web应用程序的框架通常都不允许调用从任何特定脚本(如基于php的内容)或html文档内联实现的javascript函数。甚至node.js等



谢谢:)



亚瑟。
The solution of this problem is to re-work a html web-page having inline javascript functions and specific php-script for this page so that the javascript function you're about invoke while executing php-script will be called prior to any of functions in php-script. The returning value computed by this javascript function will easily be passed to one or multiple functions inside php-script by using AJAX requests, and you'll no longer need to invoke a javascript function while executing php-script.

Unfortunately, none of the existing framework for creating web applications, except for Microsoft ASP.NET, normally allows to invoke javascript functions implemented inline of a html document from any specific scripts such php-based or even node.js, etc.

Thanks :)

Arthur.


这篇关于我可以从外部PHP文件调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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