Передача данных формы Ajax в API - PullRequest
0 голосов
/ 29 сентября 2018

Ниже код не удастся, он показывает сообщение об ошибке .. любой может помочь

$.ajax({
  type: 'GET',
  url: 'xyz.com/form_api.php',
  data: {
    name: 'John',
    email: '123333',
    mobile: 'deep@gmail.com',
    message: 'Test'
  },
  success: function(response) {
    console.log(response);
    $('#contact_form #contact_results2').html('Success');
  },
  error: function(errorThrown) {
    console.log(errorThrown);
    $('#contact_form #contact_results2').html('failed');
  }
});

1 Ответ

0 голосов
/ 29 сентября 2018

Попробуйте этот код:

$.ajax({ 
        type: 'GET', 
        url: 'xyz.com/form_api.php', 
        data: { 'name': 'John', 'email': 'deep@gmail.com', 'mobile': '123333', 'message': 'Test' 
    }, 
    success: function(response) 
    { 
        console.log( response ); 
        $("#contact_form #contact_results2").html("Success"); 
    }, 
    error: function(errorThrown) 
    { 
        console.log( errorThrown ); 
        $("#contact_form #contact_results2").html("failed"); 
    }, 
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...