如何使用 jquery 和 ajax 在第三方 url 中使用 get 方法提交表单


How do i submit a form using get method in third party url using jquery and ajax?

我想在我的word新闻项目中使用ajax和GET方法提交一个表单。

尝试了两种方法,但这对我不起作用,我的代码中有任何问题。

方法 1 使用 $.get

$.get( "http://**.70.120.**/web/sms.aspx", { fullname: "John", contactnumber: "123333",Email_ID:"aniruddha@thinkbar.in",State:"MP",City:"Indore",Magma_Customer:"YES",Proposal_Number:"1234567890",Service_type:"CASE",Query_Type:"Test type",Message:"Hellotesting" } )
  .done(function( data ) {
    alert( "Data Loaded: " + data );
  })
  .fail(function( data ) {
    alert( "Data NOT Loaded: " + data );
     });

使用 Ajax 的方法 2

     $.ajax({
  method: "GET",
  url: "http://**.70.120.**/webleads/sms.aspx",
  data: {fullname: "John", contactnumber: "123333",Email_ID:"aniruddha@thinkbar.in",State:"MP",City:"Indore",Magma_Customer:"YES",Proposal_Number:"1234567890",Service_type:"CASE",Query_Type:"Test type",Message:"Hellotesting" }
})
  .done(function( msg ) {
    alert( "Data Saved: " + msg );
  }) 
  .fail(function( msg ) {
    alert( "Data NOT Saved: " + msg );
  })

请帮忙

你可以这样做

$.ajax({
    type: 'GET',
    url: 'http://**.70.120.**/webleads/sms.aspx',
    data: {
        'fullname': 'John', 
        'contactnumber': '123333',
        'Email_ID': 'aniruddha@thinkbar.in',
        'State': 'MP',
        'City': 'Indore',
        'Magma_Customer': 'YES',
        'Proposal_Number': '1234567890',
        'Service_type': 'CASE',
        'Query_Type': 'Test type',
        'Message': 'Hellotesting'
    },
    dataType: 'application/x-www-form-urlencoded',
    success: function(response) { 
        console.log( response );
    },
    error: function(errorThrown) {
        console.log( errorThrown );
    },
});

将在您的服务器上提交的 URL 将被http://**.70.120.**/webleads/sms.aspx/?fullname=John&contactnumber=123333&Email_ID=aniruddha@thinkbar.in&State=MP&City=Indore&Magma_Customer=YES&Proposal_Number=1234567890&Service_type=CASE&Query_Type=Test%20type&Message=Hellotesting

如果你想使用ajax

$.ajax({
    data: { fullname: "John", contactnumber: "123333",Email_ID:"aniruddha@thinkbar.in",State:"MP",City:"Indore",Magma_Customer:"YES",Proposal_Number:"1234567890",Service_type:"CASE",Query_Type:"Test type",Message:"Hellotesting" },
    url: "http://**.70.120.**/web/sms.aspx",
    type: "GET",
    success: function(msg){
      //some function here
    }
});