从PHP执行jQuery代码 [英] executing jquery code from php

查看:93
本文介绍了从PHP执行jQuery代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$("#bt-potrdi").click( function(e) {    
        e.stopPropagation();        
        $("#belina").css({"z-index":200}); $("body").addClass("ext");
        $("#vpisok_frame").css({"z-index":250}).fadeIn(200);        
    });

当我单击按钮时,此jQuery代码将执行并正常工作.我可以在没有点击事件的情况下执行此代码吗?

when i click on button this jquery code is executed and works fine. Can i execute this code without click event?

例如当某些数据成功执行时,我想从php执行此代码

I want to execute this code from php when some data is executed successfully like for example

if ($ok) {
?>
//execude ajax code
e.stopPropagation();        
            $("#belina").css({"z-index":200}); $("body").addClass("ext");
            $("#vpisok_frame").css({"z-index":250}).fadeIn(200);    
<?php
}

这可能吗? PHP是服务器端代码,因此如果可能,我没有找到任何好的示例

is this possible? PHP is server side code so i didn't find any good example if this is possible

推荐答案

如果我理解这个问题,并且$ok为true,则希望在页面加载时执行一些javascript.为此,您应该可以执行以下操作:

If I understand the question, you want to execute some javascript on page load if $ok is true. To do that, you should be able to do something like:

if ($ok) {
?>
<script type="text/javascript">
   //execute ajax code
   $("#belina").css({"z-index":200}); $("body").addClass("ext");
   $("#vpisok_frame").css({"z-index":250}).fadeIn(200);    
</script>
<?php
}

此外,由于e在任何地方都没有定义,因此e.stopPropagation();将不起作用.

Also, e.stopPropagation(); is not going to work because e is not defined anywhere.

这篇关于从PHP执行jQuery代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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