0

Anybody know the correct syntax for updating a row in Google Spreadsheets using the Javascript API?

I'm working off of the API documentation here and I can't figure out what is the correct syntax I need to send the data in. What I have currently is:

var serialObject = $('#basicForm').serialize();
$.ajax({
        url: updateBasicUrl,
        type: 'PUT',
        data: serialObject,
    });

What should the syntax of the data field be (the above throws an unidentifiable error)?

EDIT - after converting a JSON object to XML to conform to the exact look of the xml here, it still doesn't work:

var updateBasicUrl = "https://spreadsheets.google.com/feeds/list/*spreadsheetIDnumber*/od6/private/full/*cellID*/*versionnumber*?access_token=*accesstoken*
$.ajax({
        url: updateBasicUrl,
        type: 'PUT',
        contentType: 'application/atom+xml',
        //contentType: 'text/xml',  //tried both of these, they don't seem to work
        data: xmlBasic,
    })

EDIT - So it seems there is a Cross-Domain Origin problem. The Google Spreadsheets API won't allow it. Anybody know of a work-around?

4

1 回答 1

0

您可以搜索解决方案的 java 源代码 - http://code.google.com/p/gdata-java-client/source/browse/trunk/java/src/com/google/gdata/client/spreadsheet/SpreadsheetService .java?r=94

这会触发 java 版本中的发送: service.insert(cellFeedUrl, newEntry);

public void setCell(int row, int col, String formulaOrValue)
    throws IOException, ServiceException {

  CellEntry newEntry = new CellEntry(row, col, formulaOrValue);
  service.insert(cellFeedUrl, newEntry);
  out.println("Added!");
}
于 2013-02-07T00:31:41.783 回答