$.getJSON \ $.ajax

來源:互聯網
上載者:User

標籤:round   for   方法   family   update   ati   html   blog   log   

一、在js中的寫法

  1. $.getJSON

1 $.getJSON(url, function(data){3   // 1. data 是 Gson結構的,可以直接使用5   // 2. $.getJSON 用的 get方式提交,因此當提交的url中有中文的話,會被解析成jsp當前的編碼提交給action,然後再action中會變成頭痛的中文亂碼7 });

  2. $.ajax

 1 $.ajax({ 2   type:"POST", //設定成POST,可以避免提交到action中出現的亂碼 3   dataType:"json", 4   async:false, //這裡寫了,才會進入到success方法裡面 5   url:"blbooking.do?method=updateBlBooking", 6  // data:$(‘#yourformid‘).serialize(),// 你的formid 7   data:{"cm":"${cm}"},// 你的formid 8   success: function(data) { 9     alert("成功");
14   error: function() {15     alert("失敗");16   }17 });

   3. $.get()  $.post()

    還沒用到,可以參考http://www.cnblogs.com/dongsh/p/3235487.html

二、在action中的寫法

super.renderText(response, jsonObject.toString());

 

$.getJSON \ $.ajax

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.