如何发送通过JavaScript和放大器'放'的要求;阿贾克斯?放大器、JavaScript、阿贾克斯

2023-09-10 21:36:14 作者:草莓味的猪猪

我要写信给我的小号preadsheet编程。它可以让我写上的S preadsheet特定的细胞。我的code是:

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);
                    }
                });
            }

我可以只使用XML元素写为s preadsheet。所以,我创建(new.xml):

I can write to spreadsheet using xml element only. So, I have created (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>

不过,C是我的$ C $仍然抛出一个错误。我认为这是关系到XML文件,我写。我认为,创造new.xml是我的错误。请建议如何写回信吗?如何创建一个XML元素?

But, my code it is still throwing an error. I think it is related to the XML file I am writing. I think, creating new.xml is my error. Please suggest how to write back? How do I create an xml element ?

有关referece:更新细胞

For referece : Update Cells

输出: A : [对象的对象]

Output : a : [object Object]

B: 未定义

C:

推荐答案

由于同源策略的限制无法发送AJAX请求跨域。在这里,您试图发送一个Ajax请求 HTTPS://s$p$padsheets.google.com 键,除非你的网站托管在 HTTPS ://google.com 这是不行的。为了尽量解决这个限制,你可以写你的服务器上的服务器脚本将作为您的域名和google.com之间的桥梁。然后,你可以发送AJAX请求到你的脚本将委托。

Due to same origin policy restriction you cannot send AJAX requests cross domain. 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. 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. Then you could send the AJAX request to your script which will delegate.

 
精彩推荐
图片推荐