Uncaught TypeError: jQuery.ajax(...).success is not a function

Рейтинг: 0Ответов: 0Опубликовано: 23.02.2023

Всем привет.

JS

 (function($) {
                $(function() {
                    
                    jQuery('#quote_form').on('submit', function(e){
                        e.preventDefault();
                        jQuery('.btn ').attr('disabled','disabled');
                        jQuery('#quote_form').addClass('form_sending');
                        var request = {
                            option       : 'com_ajax',
                            module       : 'c_form',
                            method       : 'sendMail',
                            format       : 'row',   
                            data: jQuery('#quote_form').serialize(),    
                            src: window.location.href,
                        };
                        jQuery.ajax({
                            method: 'POST', 
                            data: request,
                            
                        })
                        .success(function(response){
                            console.log(response);
                            jQuery(location).attr('href', window.location.origin + '/thanks-you-for-contacting');
                        });
                    });
                }); 
            })(jQuery);
        

PHP

<?php 
 
 
 
require_once '../../configuration.php'; 
 
$jconfig = new JConfig(); 
 
$host   = $jconfig->host; 
$dbname  = $jconfig->db; 
$username  = $jconfig->user; 
$password  = $jconfig->password; 
$dbprefix  = $jconfig->dbprefix; 
 
$db = mysqli_connect($host, $username, $password, $dbname); 
if (!$db) { 
    die('Ошибка соединения: ' . mysqli_error()); 
} 
$stmt = $db->prepare('SELECT params FROM ' . $dbprefix .'template_styles WHERE template = "easy_moving"'); 
$stmt->execute(); 
$result = $stmt->get_result(); 
$row = $result->fetch_assoc(); 
$params = json_decode($row['params']); 
mysqli_close($db); 
 
 
$to = $params->email; 
 
$subject = $_POST['subject'];  
$mailheaders = "Content-type:text/html;charset=utf-8rn";  
$mailheaders .= "From: SiteRobot <noreply@easy-moving.ca/>rn";  
$mailheaders .= "Reply-To: [email]noreply@easy-moving.ca[/email]/";  
 
if ($subject == 'Free Quote') { 
 $message = 
 '<table> 
  <tbody> 
   <tr> 
    <td>Moving From</td> 
    <td>'. $_POST['movingfrom'] .'</td> 
   </tr> 
   <tr> 
    <td>Moving To</td> 
    <td>'. $_POST['movingto'] .'</td> 
   </tr> 
   <tr> 
    <td>Contact Phone</td> 
    <td>'. $_POST['phone'] .'</td> 
   </tr> 
   <tr> 
    <td>Full Name</td> 
    <td>'. $_POST['fullname'] .'</td> 
   </tr> 
   <tr> 
    <td>Email Address</td> 
    <td>'. $_POST['email'] .'</td> 
   </tr> 
   <tr> 
    <td>Moving Date</td> 
    <td>'. $_POST['movingdate'] .'</td> 
   </tr> 
   <tr> 
    <td>What Size?</td> 
    <td>'. $_POST['whatsize'] .'</td> 
   </tr> 
   <tr> 
    <td>How did you hear about us?</td> 
    <td>'. $_POST['howdid'] .'</td> 
   </tr> 
  </tbody> 
 </table>'; 
} 
 
elseif ($subject == 'Free Estimate Online') { 
 $message = 
 '<table> 
  <tbody> 
   <tr> 
    <td>Full Name</td> 
    <td>'. $_POST['fullname'] .'</td> 
   </tr> 
   <tr> 
    <td>Email Address</td> 
    <td>'. $_POST['email'] .'</td> 
   </tr> 
   <tr> 
    <td>Contact Phone</td> 
    <td>'. $_POST['phone'] .'</td> 
   </tr> 
   <tr> 
    <td>Moving From</td> 
    <td>'. $_POST['movingfrom'] .'</td> 
   </tr> 
   <tr> 
    <td>Moving To</td> 
    <td>'. $_POST['movingto'] .'</td> 
   </tr> 
   <tr> 
    <td>Moving Date</td> 
    <td>'. $_POST['movingdate'] .'</td> 
   </tr> 
   <tr> 
    <td>Move Size</td> 
    <td>'. $_POST['movesize'] .'</td> 
   </tr> 
   <tr> 
    <td>Truck Size</td> 
    <td>'. $_POST['trucksize'] .'</td> 
   </tr> 
   <tr> 
    <td>Сomments</td> 
    <td>'. $_POST['comments'] .'</td> 
   </tr> 
  </tbody> 
 </table>'; 
} else { 
 die('error'); 
} 
 
 
 
$res = mail($to, $subject, $message, $mailheaders); 
echo $res; 
 
?>zz

Получаю ошибку Uncaught TypeError: jQuery.ajax(...).success is not a function

Пишу для Ajax

        $(document).ready(() => {
        $('#quote_form').on('submit', function () {
            jQuery('#quote_form').addClass('form_sending');
            $.ajax({
                url: 'process.php', 
                type: 'POST',
                data: jQuery('#quote_form').serialize(),    
                success:function(response) {
                  $('.responseArea').html(response);
                },
                statusCode:{
                  404:function(){
                    //$('.error').html("Page not found!");
                    alert( "file not found" );
                  }
                }
              }).done(function() {
              alert( "success" );
              }).fail(function() {
              alert( "error" );
              }).always(function() {
              alert( "complete" );
            }); 
        });
    });

попадаю в fail

Ответы

Ответов пока нет.