如果不允许跨域ajax调用,那么你应该如何使用google电子表格API [英] If cross domain ajax calls are not allowed then how are you supposed to use the google spreadsheet API

查看:184
本文介绍了如果不允许跨域ajax调用,那么你应该如何使用google电子表格API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果不允许跨域ajax调用,那么您应该如何进行注意:已过时的链接。



从链接; (开发人员指南:协议v 2.0 - Google Spreadsheets API):



添加行



要向表中添加一行,首先创建一个包含相关数据的< entry> 元素:

 < entry> 
< gsx:hours> 1< / gsx:hours>
< gsx:ipm> 1< / gsx:ipm>
< gsx:items> 60< / gsx:items>
< gsx:name> Elizabeth Bennet< / gsx:name>
< / entry>

然后确定要发送条目的适当URL,称为。您可以在列表供稿的< link> 元素中找到POST URL,该元素具有 rel =http://schemas.google.com/g / 2005#post



接下来,执行任何必要的身份验证,并为新的POST请求创建授权头



在POST请求的正文中,将 Atom < entry>



现在发送一个 对POST网址的请求:


  POST http://spreadsheets.google.com/feeds / list / key / worksheetId / private / full 


电子表格

解决方案

跨域ajax限制只是浏览器限制。如果从服务器或其他应用程序进行Web服务调用,则不会受到限制。如果你需要进行ajax调用,你可以通过你的服务器代理调用。


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.

解决方案

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.

这篇关于如果不允许跨域ajax调用,那么你应该如何使用google电子表格API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆