[英]how do I send 'put' request through javaScript & Ajax?
I have to write to my spreadsheet programatically. 我必须以编程方式写入电子表格。 It allows my to write to a particular cell of the spreadsheet.
它允许我写入电子表格的特定单元格。 My code is :
我的代码是:
function update(){
jQuery.ajax({
type: 'PUT',
contentType: "application/atom+xml",
url: "https://spreadsheets.google.com/feeds/cells/0Aq69FHX3TV4ndDBDVFFETUFhamc5S25rdkNoRkd4WXc/od6/private/full/R2C1",
dataType: "xml",
data: "new.xml",
success: function() {
alert('Put Success');
},
error: function(a,b,c) {
console.log("XMLHttpRequest: " + a);
console.log("textStatus: " + b);
console.log("errorThrown: " + c);
alert("XMLHttpRequest : " + a + " textStatus : " + b + " errorThrown : " + c);
}
});
}
I can write to spreadsheet using xml element only. 我只能使用xml元素写入电子表格。 So, I have created (new.xml):
因此,我创建了(new.xml):
<entry>
<id>https://spreadsheets.google.com/feeds/cells/0Aq69FHX3TV4ndDBDVFFETUFhamc5S25rdkNoRkd4WXc/od6/private/full/R2C1</id>
<link rel="edit" type="application/atom+xml"
href="https://spreadsheets.google.com/feeds/cells/0Aq69FHX3TV4ndDBDVFFETUFhamc5S25rdkNoRkd4WXc/worksheetId/private/full/R2C1"/>
<gs:cell row="2" col="1" inputValue="300"/>
</entry>
But, my code it is still throwing an error. 但是,我的代码仍然抛出错误。 I think it is related to the XML file I am writing.
我认为它与我正在编写的XML文件有关。 I think, creating new.xml is my error.
我认为,创建new.xml是我的错误。 Please suggest how to write back?
请建议如何回信? How do I create an xml element ?
如何创建xml元素?
For referece : Update Cells 供参考: 更新单元格
Output : a : [object Object] 输出:a:[对象对象]
b : undefined b:未定义
c : C :
Due to same origin policy restriction you cannot send AJAX requests cross domain. 由于相同的来源政策限制,您无法跨域发送AJAX请求。 Here you are trying to send an AJAX request to
https://spreadsheets.google.com
and unless your site is hosted on https://google.com
this won't work. 在这里,您尝试将AJAX请求发送到
https://spreadsheets.google.com
,除非您的网站托管在https://google.com
上,否则这将无法工作。 To try to workaround this restriction you could write a server script on your server which will serve as a bridge between your domain and google.com. 要尝试解决此限制,您可以在服务器上编写服务器脚本,该脚本将充当您的域和google.com之间的桥梁。 Then you could send the AJAX request to your script which will delegate.
然后,您可以将AJAX请求发送到将委托的脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.