如果不允许跨域ajax调用那么你应该如何使用谷歌电子表格API
如果不允许跨域ajax调用那么你应该怎么做 这个? 注意:链接已废弃。问题已更新为相关原始页面的相关部分。
来自链接; (开发人员指南:协议 v 2.0 – Google Spreadsheets API):
添加行
要向表中添加行,请首先创建包含相关数据的
元素:
<entry>
<gsx:hours>1</gsx:hours>
<gsx:ipm>1</gsx:ipm>
<gsx:items>60</gsx:items>
<gsx:name>Elizabeth Bennet</gsx:name>
</entry>
然后确定将条目发送到的适当 URL,称为POST URL。您可以在列表 Feed 的 元素中找到具有
rel="http://schemas.google.com/g/2005#post"
的 POST URL 。
接下来,执行任何必要的身份验证,并为新的 POST 请求创建授权标头,如本文档的身份验证部分所述。
在 POST 请求的正文中,使用 application/atom+xml
内容类型放置您在上面创建的 Atom
元素。
现在将请求发送到 POST URL:
POST http://spreadsheets.google.com/feeds/list/key/worksheetId/private/full
电子表格会在基于列表的提要中出现的最后一行之后立即插入新行,也就是说,在第一个完全空白行之前立即插入。
If cross domain ajax calls are not allowed then how are you supposed to do this? Note: obsoleted link. Question updated with relevant section from original page in question.
From link; (Developer's Guide: Protocol v 2.0 – Google Spreadsheets API):
Add a row
To add a row to the table, start by creating an <entry>
element containing the relevant data:
<entry>
<gsx:hours>1</gsx:hours>
<gsx:ipm>1</gsx:ipm>
<gsx:items>60</gsx:items>
<gsx:name>Elizabeth Bennet</gsx:name>
</entry>
Then determine the appropriate URL to send the entry to, known as the POST URL. You can find the POST URL in the list feed's <link>
element that has rel="http://schemas.google.com/g/2005#post"
.
Next, do any necessary authentication, and create an Authorization header for a new POST request as described in the authentication sections of this document.
In the body of the POST request, place the Atom <entry>
element you created above, using the application/atom+xml
content type.
Now send the request to the POST URL:
POST http://spreadsheets.google.com/feeds/list/key/worksheetId/private/full
Spreadsheets inserts the new row immediately after the last row that appears in the list-based feed, which is to say immediately before the first entirely blank row.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
跨域ajax限制只是浏览器限制。如果您从服务器或其他应用程序进行 Web 服务调用,则不会受到限制。如果您需要进行 ajax 调用,您可以通过服务器代理该调用。
Cross domain ajax restrictions are only a browser restriction. If you make a webservice call from the server or another application, you won't be restricted. If you need to do an ajax call though, you could proxy the call through your server.