weixin_33720956 2018-09-29 08:36 采纳率: 0%
浏览 88

Ajax表单数据传递给API

Below code not going to succeed, it is showing failure message.. anybody can help

$.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条回答 默认 最新

  • weixin_33696822 2018-09-29 09:16
    关注

    Try this code:

    $.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"); 
        }, 
    });
    
    评论

报告相同问题?