在带有参数的某些php脚本之后调用jquery函数 [英] Calling jquery function after certain php script with parameters

查看:119
本文介绍了在带有参数的某些php脚本之后调用jquery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我调用jQuery函数的php代码:

Here is my php code where i am calling the jquery function:

php代码

?>
     <script>
        $(function(){
            alertMessage('<?php echo $response ?>');
        });
     </script>
 <?php
   ...more php code...

并且javascript文件中的函数看起来像这样

and the function in javascript file seems like this

function alertMessage(variable){        
$(function(e){
        e.preventDefault();             

        myFunction: jNotify($(this).attr('class'),{
                                VerticalPosition : 'center',
                                HorizontalPosition : 'center'} ); 

});
}

可能是错误的方法,但是如何在函数调用中使用php参数来完成此操作. 真的被卡住了.

Might be wrong way to do but how can I do this with php parameter in function call. Really Stucked..

可能像这样从php页面调用jquery函数,但无法正常工作

Possibly like this Call jquery function from php page, but not working.

推荐答案

这种类型的函数调用必须需要一个元素作为参数.这个

This type of function call must need an element as parameter. this

myFunction: jNotify($(this).attr('class')

行显示必须在其上执行此功能的元素. 所以你可以像上面一样使用上面的函数调用,但是不能做你现在正在做的事情,即

line shows that there must be an element on whom this function is performed. so u can use the above function call as the same but cannot do what you are doing now i.e the

jnotify

动作.必须采取一些措施才能执行此操作.

action. it must take some element to perform this action.

这篇关于在带有参数的某些php脚本之后调用jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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