2011-01-22 121 views
3

我想在授權用戶後寫回到我的google電子表格。授權完成。但是,要回寫到電子表格,我已經發送PUT請求,如here所述。它來自iGoogle小工具。如何從jQuery發送ajax請求請求

我的XML元素是:

var cellUrl = "https://spreadsheets.google.com/feeds/cells/" + key + "/od6/private/full/R2C2"; 
var XMLData = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gs='http://schemas.google.com/spreadsheets/2006'>" + 
       "<id>" + cellUrl + "</id><link rel='edit' type='application/atom+xml' href='" + cellUrl + "'/>" + 
       "<gs:cell row='2' col='2' inputValue='300'/>" + 
      "</entry>"; 

我送AJAX請求爲:

$.ajax({ 
       url: cellUrl, 
       type: "PUT", 
       contentType: 'application/atom+xml', 
       processData: false, 
       data: XMLData, 
       error: function(XMLHttpRequest, textStatus, errorThrown){ 
        alert(errorThrown); 
       }, success: function(data, textStatus, XMLHttpRequest){ 
        alert("Succeeded"); 
       } 
      }); 

不過,它不是寫回,並沒有表現出以及任何警報!什麼是問題?

我應該使用POST寫回嗎?我怎麼做 ?

爲了安全,我隱藏了cellURL鍵。它與我的電子表格網址中的鍵相似。

+1

氣味像一個StackOverflow.com問題... – Lipis 2011-01-22 15:06:16

+0

你可以檢查請求實際上提交的地方嗎?你可以使用螢火蟲/開發工具。 – 2011-01-24 07:38:33

回答

0

我的建議

  • 檢查「鑰匙」 RESOURCEID應該逃避
  • 如果仍無法正常工作,儘量把所有內容都添加並使用點擊事件。對於ajax,請使用iframe。試試$ .ajax({...,data:$(XMLData),...});
0

你可以嘗試這樣的事情,看看是否有錯誤:

$.ajax({ 
     url: cellUrl, 
     type: "PUT", 
     contentType: 'application/atom+xml', 
     processData: false, 
     data: XMLData 
    }, error: function(XMLHttpRequest, textStatus, errorThrown){ 
     alert(errorThrown); 
    }, success: function(data, textStatus, XMLHttpRequest){ 
     alert("Succeeded"); 
    } 

);