JSONP将数据发布到其他域

问题描述 投票:0回答:1

我试图通过搜索一段时间来找到答案,但是我没有找到我需要的东西。

所以我有这些输入框。

  <div>
  Kontaktuppgifter<br>
  <input class="double" type="text" name="customer_firstName" placeholder="Förnamn" />
  <input class="double" type="text" name="customer_surName" placeholder="Efternamn" />
  <input class="double" type="email" name="customer_email" placeholder="Epost" />
  <input class="double" type="tel" name="customer_cellnr" placeholder="Mobilnummer" />
  </div>

  <div>      
  Adressuppgifter<br>
  <input type="text" name="customer_adress" placeholder="BostadsAdress" />
  <input type="text" name="customer_zipcode" placeholder="{{postal_code_label}}" />
  <input type="text" name="customer_city" placeholder="Ort" />
  <input type="text" name="customer_country" placeholder="Land" />
  </div>

  <div>
  Garantispecifika uppgfiter<br>
  <input type="text" name="customer_housenr" placeholder="Fastighetsbeteckning" />
  <input type="text" name="customer_persnumber" placeholder="Personnummer" />
  </div>

  <div>
  Företagsspecifika uppgifter - Fylls bara i av företag<br>
  <input type="text" name="customer_companyName" placeholder="Företagsnamn" />
  <input type="text" name="customer_Orgnr" placeholder="Organisationsnummer" />
  <input id="send_message" class="button secondary" type="submit" value="Registrera Garanti" onclick="postFrom(this)"/>
  </div>

现在,我想通过JSONP发送所有数据。

我可以使用它,属性'customer_name = json'

我应如何将所有内容连接起来,以将其发送给处理程序?

data:我可以使用的唯一标签,或者该如何构造调用?

$.ajax({
   type: 'GET',
   url: 'http://www.mypage.com/offerthandler.ashx',
   crossDomain: true,
   data: 'customer_name=json',
   dataType: 'jsonp',
   success: function(responseData, jsonobj) {
   alert('POST Successfull.');

},
error: function (responseData, textStatus, errorThrown) {
    alert('POST failed.');
}
 });

我应该去

 data: 'customer_firstName=$('[name="customer_firstName"]').val() + 
        customer_surName=$('[name="customer_surName"]').val()

依此类推,或者我该怎么做?

jsonp
1个回答
0
投票

一种简单的方法是,插入标签为表单提供一个ID并序列化该表单。

© www.soinside.com 2019 - 2024. All rights reserved.