简体   繁体   English

使用 Jquery 更改 css 的问题

[英]Issue with changing css with Jquery

在此处输入图片说明

I am trying to make 2 step checkout modal我正在尝试制作两步结帐模式

My first step modal is inside div with id ="step1" and with style display block我的第一步模式是在 id ="step1" 和样式显示块的 div 内

and step2 with id="step2" with style display none和带有 id="step2" 样式的 step2 显示无

My buttons inside my modal footer:我的模态页脚中的按钮:

<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="check_address();" id="next_button">Next >></button>
<button type="button" class="btn btn-primary" onclick="back_address();" id="back_button" style="display:none;">Back <<</button>

<button type="submit" class="btn btn-primary" id="checkout_button" style="display:none;">Check Out >></button>

Inside my cart.php file I have an function check_address that corresponds to parser file and ajax that looks like this:在我的 cart.php 文件中,我有一个函数 check_address 对应于解析器文件和 ajax,如下所示:

function check_address() {
    var data = {
        'full_name': jQuery('#full_name').val(),
        'email': jQuery('#email').val(),
        'street': jQuery('#street').val(),
        'street2': jQuery('#street2').val(),
        'city': jQuery('#city').val(),
        'state': jQuery('#state').val(),
        'zip_code': jQuery('#zip_code').val(),
        'country': jQuery('#country').val(),

    };
    jQuery.ajax({
        url: '/E-Shop/admin/parsers/check_address.php',
        method: 'POST',
        data: data,
        success: function(data) { //this data is what is forwarded back from the parser file
            if (data != 'passed') {
                jQuery('#payment-errors').html(data);
            }
            if (data == 'passed') {
                jQuery('#payment-errors').html("");
                jQuery('#step1').css("display", "none");
                jQuery('#step2').css("display", "block");
                jQuery('#next_button').css("display", "none");
                jQuery('#back_button').css("display", "inline-block");
                jQuery('#checkout_button').css("display", "inline-block");

            }
        },
        error: function() {
            alert("An error occured!");
        },
    });
}

After I submit my first step form, I get output from check_adress.php parser : "passed" from my last line in check_address.php提交第一步表单后,我从 check_adress.php 解析器获得输出:从 check_address.php 中的最后一行“通过”

if(!empty($greske)){
    echo display_greske($greske);
}else{
    echo 'passed';
}

my check_address.php script: https://pastebin.com/1qA5Tx08我的 check_address.php 脚本: https ://pastebin.com/1qA5Tx08

but the jQuery doesn't show or change my css display attributes但 jQuery 不显示或更改我的 css 显示属性

删除check_address.php脚本开头<?php之前的空行。

jQuery.ajax({
    url :url,
    type : 'post',
    data : data,
    success : function (data) {
    //    location.reload(); 
        if (data != 'passed') {
            jQuery('#payment_errors').html(data);
        }
        if (data == 'passed') {
            // alert('passed');
            //clear errors
            jQuery('#payment_errors').html("");
            jQuery('#step1').css("display","none");
            jQuery('#step2').css("display","block");
            jQuery('#next_button').css("display","none");
            jQuery('#back_button').css("display","inline-block");
            jQuery('#check_out_button').css("display","inline-block");
        }

    },
    error : function () {
        alert("Something wrong with the child options.");
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM