2013-10-02 61 views
1

我越來越頭痛如何從jquery/ajax/json rpc調用中檢索我的數據服務器端!jquery ajax json rpc如何檢索服務器上的數據

下面是客戶端:

 $.ajax({ 
     type: 'POST', 
     contentType: 'application/json; charset=utf-8', 
     url: 'http://wine-trip.net/php/ajax/setVinImage.php', 
     data: JSON.stringify({jsonrpc:'2.0',method:'add',params:[{'vigneronID':'14818','action':'deleteImage','vinID':'13','vinImageType':'Bouteille'}],id:"jsonrpc"}), 
     dataType:"json", 
     success:function(data){ 
      if (typeof (data.error.message) === 'undefined') { 
       // Everything was OK 
      } 
      else{ 
       alert(data.error.message); 
      }    
     }, 
     error: function(req) { 
      alert("Networking problem"); 
     } 
    }); 

,這裏是服務器端的開始:

// HTTP headers for no cache etc 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache"); 

error_log("POST ".$_POST['vigneronID'], 0); 
error_log("REQUEST ".$_REQUEST['vigneronID'], 0); 

我得到警報顯示從服務器的答案,但不能存取權限的數據我正在傳遞參數(壞語法?)。

我可以做一個正常的ajax調用,但由於我使用plupload庫(它與json rpc一起工作),我想弄清楚爲什麼我不能使用這種方法!

我已經試過有或無的contentType但似乎並沒有改變任何東西......

回答

相關問題