Jowed
Jowed

Reputation: 13

Ajax request not going through

I m working on a project and this is my code according to my research this should go through but its not

Can some please have a look at this

function check_address1(){
        var data = {
            'full_name1' : jQuery('#full_name1').val(),
            'street1' : jQuery('#street1').val(),
            'street21' : jQuery('#street21').val(),
            'city1' : jQuery('#city1').val(),
            'county1' : jQuery('#county1').val(),
            'postcode1' : jQuery('#postcode1').val(),
            'country1' : jQuery('#country1').val(),
        };
    jQuery,ajax({
             url : '/project/admin/parsers/check_address1.php',
             method : 'post',
             data : data,
             success : function(data){
                if(data != 'good'){
                    Query('#payment-errors').html(data);
                }
                if (data == 'good') {
                    jQuery('#payment-errors').html("");
                    jQuery('#step1').css("display",'none');
                    jQuery('#step2').css("display",'none');
                    jQuery('#step3').css("display",'block');
                    jQuery('#next_button').css("display",'none');
                    jQuery('#take1').css("display",'none');
                    jQuery('#take2').css("display",'inline-block');
                    jQuery('#next_button').css("display",'none');
                    jQuery('#next_button1').css("display",'none');
                    jQuery('#checkout_button')css("display",'inline-block');
                    jQuery('#checkoutModalLabel').html("Enter your card details")

                }
             },
             error : function(){alert("Something Went Wrong");},
    });
    }

Thank you in advance

Upvotes: 0

Views: 30

Answers (1)

comunit
comunit

Reputation: 86

You have a couple of errors in your code

  1. jQuery,ajax({ should be jQuery.ajax({
  2. Query('#payment-errors').html(data); should be jQuery('#payment-errors').html(data);
  3. missing . in jQuery('#checkout_button')css("display",'inline-block');

Here is correct code

function check_address1(){
        var data = {
            'full_name1' : jQuery('#full_name1').val(),
            'street1' : jQuery('#street1').val(),
            'street21' : jQuery('#street21').val(),
            'city1' : jQuery('#city1').val(),
            'county1' : jQuery('#county1').val(),
            'postcode1' : jQuery('#postcode1').val(),
            'country1' : jQuery('#country1').val(),
        };
    jQuery.ajax({
             url : '/project/admin/parsers/check_address1.php',
             method : 'post',
             data : data,
             success : function(data){
                if(data != 'good'){
                    jQuery('#payment-errors').html(data);
                }
                if (data == 'good') {
                    jQuery('#payment-errors').html("");
                    jQuery('#step1').css("display",'none');
                    jQuery('#step2').css("display",'none');
                    jQuery('#step3').css("display",'block');
                    jQuery('#next_button').css("display",'none');
                    jQuery('#take1').css("display",'none');
                    jQuery('#take2').css("display",'inline-block');
                    jQuery('#next_button').css("display",'none');
                    jQuery('#next_button1').css("display",'none');
                    jQuery('#checkout_button').css("display",'inline-block');
                    jQuery('#checkoutModalLabel').html("Enter your card details")

                }
             },
             error : function(){alert("Something Went Wrong");},
    });
    }

Upvotes: 1

Related Questions