顯示具有 ajax 標籤的文章。 顯示所有文章
顯示具有 ajax 標籤的文章。 顯示所有文章

jquery getJSON and ajax functions for calling JSON-based web services

網頁端利用jquery提供的高階javascript方法getJSON或ajax取用其他網頁服務的寫法,資料傳收過程皆採用json格式:

  $.getJSON( "http://host:port/path",
      {bookID:"1309088",format:"json"})
    .done(function( data ) {
      var output = "";
      for(var i in data.items){
         output ="<li>" + data.items[i].value + "," + data.items[i].id + "," + data.items[i].name + "</li>\n";
         $('#result').append(output);
      }
    })
    .fail(function() {
       window.alert("fail");
    });
  //--
  $.ajax({
      url: 'http://host:port/path',   //存取Json的網址
      type: 'post',
      cache:false,
      dataType: 'json', // format expected from server
      contentType: 'application/json; charset=utf-8', // format sent to server
      data: JSON.stringify({bookID:"1309088}),
    success: function (data) {
      html = '<table>';
      i=1;
      $.each(data, function () {
          html +=  '<tr><td>' + data[i]['model'] + '</td>'
                   ' + data[i]['epoch'] + '</td></tr>\n';
         i++;
      });
      html += '</table>';

      document.getElementById("list_model").innerHTML = html;
    },
    error: function (xhr, ajaxOptions, thrownError) {
      document.getElementById("result").innerHTML =
        'internal error(' + xhr.status + ',' + thrownError + '), try again...';
    }
  });

Installing Code::Blocks on Windows for APCS Preparation

APCS 為大學程式設計先修檢測 (Advanced Placement Computer Science),其檢測等級可供大學個人申請入學時,比對是否符合各電腦相關科系APCS組申請資格之用。其中,針對 C 及 C++ 程式檢測者,考場提供 Linux 環境的輕量級 Code...

總網頁瀏覽量