装载PHP页面与JavaScript类 [英] loading php page with class in javascript

查看:95
本文介绍了装载PHP页面与JavaScript类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JavaScript弹出类,并添加所需要的显示弹出式在我的HTML页面中的所有脚本。我试图加载PHP页面上提交我的表单按钮的点击弹出。

I have popup class in javascript and added all scripts in my html page that are required to display that popup. I am trying to load PHP page in that popup on submit button click of my form.

弹出工作正常的按钮如下图所示(从select.php文本显示在弹出框中):

Popup is working fine for button like below (text from select.php is showing on popup box):

<a href="select.php" class="home-banner-button popup">Activate</a>

现在我有一个表格并提交我要重定向到PHP页面视情况而定。而结果应可弹出显示。

Now I have a form and on submit I have to redirect to PHP page depending on condition. And result should be display in popup.

我试图加载我的弹出页面类如下,但它不是显示在弹出。

I tried to load page with my popup class as below but its not showing the popup.

标记类似如下:

<form method="post" action="#"  onSubmit="return check();">
   <input type="text" id="textid" placeholder="Enter Here" />
   <input type="submit" name="submit" />                
</form>

Javasript:

Javasript:

<script type="text/javascript">

$(function () {
    $('.popup').colorbox({
        iframe: true,
        opacity: 0.7,
        fixed: true,
        innerWidth: 500,
        innerHeight: 180,
        scrolling: false
    });
});

function check() {
    var price = $('#textid').val();
    var new_value = price.replace(/\,/g, '');
    var lower_limit_value = 375;
    var upper_limit_value = 1712;

    if (new_value >= lower_limit_value && new_value <= upper_limit_value) {
        $(".popup").load("correct.php");
        return false;
    } else {
        $(".popup").load("incorrect.php");
        return false;
    }
}
</script>

我想我用这个错误的语法 $(弹出)负载(correct.php);

我没有得到如何使用/我该如何调用类(如.popup)在JavaScript与装载PHP页面或这样做的其他方式。

I am not getting how to use that/how do I call a class(e.g .popup) in javascript with loading php page or other way of doing this.

或 如何使用Ajax在这种情况下?可以阿贾克斯将在这样的情况下帮助?

or How to use ajax in this case? Can ajax will help in such situation?

推荐答案

我用.colorbox()函数直接如下解决我的问题。它的做工精细了。 :)

I solved my problem by using .colorbox() function directly as below. Its working fine now. :)

<script type="text/javascript">
    function check() {
        var price = $('#textid').val();
        var new_value = price.replace(/\,/g,'');
        var lower_limit_value = 375;
        var upper_limit_value = 1712;

    if (new_value>=lower_limit_value && new_value<=upper_limit_value) {

    $.colorbox({
href:"correct.php",
iframe:true, 
opacity:0.7, 
fixed:true, 
innerWidth:500, 
innerHeight:250, 
scrolling:false});
    return false;

    } else {

    $.colorbox({
href:"incorrect.php",
iframe:true, 
opacity:0.7, 
fixed:true, 
innerWidth:500, 
innerHeight:320, 
scrolling:false});  
    return false;

    }
}

</script>

这篇关于装载PHP页面与JavaScript类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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