ajax call failed to give response in wordpress

0 views
0

hai im working in wordpress the simple concept is if the changing password if the user enters the existing password wrong need to alert the user im trying it with json message, response is receiving as undefined unable to parse the data from response.

function choice_update_password(){
    global $wpdb;
    $old_password=$_REQUEST['old_password'];
    $N_password=$_REQUEST['new_password'];
    $user = wp_get_current_user();
    $encrypt_pass= $user->data->user_pass;

     if ($user && wp_check_password( $old_password, $user->data->user_pass, $user->ID) ) {
        wp_set_password($N_password, $user->ID);
        $url="profile";
        $view_profile=site_url($url);
        echo json_encode(array("type"=>"success","data"=>"","url"=> $view_profile));
        die();
    }else{
        echo json_encode(array("type"=>"failure","data"=>""));
        die();
    }
}

and the ajax part

function mail_prop_update($clsfrm) {
  var $form = jQuery($clsfrm),$dataType = "json";
  $form.on('click', 'input[type=submit]', function(e) {
    var $elements = $form.find('input:not(input[type="submit"],input[type="button"],input[type="hidden"],input[type="file"],input[type="text"].not-required),textarea#message');
    var $bool = $elements.validate();
    var email = $form.find('input[type="email"]').val();
    var action = $form.find('input[name="action"]').val();
    if ($bool) {
      ajax_submit($form, $elements, $dataType);
    }

    alert(e.responseText.type);

    e.preventDefault();
  });
}