浏览器开发人员工具中出现错误:未捕获的ReferenceError:

时间:2017-09-13 18:10:06

标签: jquery ajax

你好,当我触发onclick按钮时,我收到以下错误:

错误:

enter image description here

在本网站检查了类似的错误及其解决方案后,他们没有为我工作。

按钮的代码如下:

 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
    <button type="button" class="btn btn-primary" onclick="check_address();">Next >></button>
  </div>
</div>

功能代码如下:

function check_address(){
    alert('passed');
    var data={
        'firstName' : jQuery('#firstName').val(),
        'lastName' : jQuery('#lastName').val(),
        'houseName' : jQuery('#houseName').val(),
        'street' : jQuery('#street').val(),
        'city' : jQuery('#city').val(),
        'postCode' : jQuery('#postCode').val(),
        'country' : jQuery('#country').val(),
        'email' : jQuery('#email').val(),
        'contactNo' : jQuery('#contactNo').val(),
    };
    jQuery.ajax({
        url : '/aresV2/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'){
                alert('passed');
            }
        },
        error: : function(){alert("An error occured!!!");},
    });
}

下面的解析器文件代码,名为check_address.php

<?php 
require_once $_SERVER['DOCUMENT_ROOT'].'/areV2/core/init.php';
$firstName=sanitize($_POST['firstName']);
$lastName=sanitize($_POST['lastName']);
$houseName=sanitize($_POST['houseName']);
$street=sanitize($_POST['street']);
$city=sanitize($_POST['city']);
$postCode=sanitize($_POST['postCode']);
$country=sanitize($_POST['country']);
$email=sanitize($_POST['email']);
$contactNo=sanitize($_POST['contactNo']);
$errors=array();
$required=array(
    'firstName' => 'Name',
    'lastName' => 'Surname',
    'houseName' => 'HouseName/No',
    'street' => 'Street',
    'city' => 'City',
    'postCode' => 'Post Code',
    'country' => 'Country',
    'email' => 'e-Mail',
);

//check if all required fieds were filled out
foreach($required as $f => $d){
    if(empty($_POST[$f]) || $_POST[$f]==''){
        $errors[] = $d.' is required!!!';
    }
}

if(!empty($errors)){
    echo display_errors($errors);
}else{
    echo 'passed';
}?>

0 个答案:

没有答案