How to send ajax put request from jQuery

I want to write back to my google spreadsheet after user authorization. Authorization completed. But, to write back to the table, I sent a PUT request, as indicated here . This is from iGoogle Gadget.

My XML element:

var cellUrl = "https://spreadsheets.google.com/feeds/cells/" + key + "/od6/private/full/R2C2";
var XMLData = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gs='http://schemas.google.com/spreadsheets/2006'>" + 
                "<id>" + cellUrl + "</id><link rel='edit' type='application/atom+xml' href='" + cellUrl + "'/>" + 
                "<gs:cell row='2' col='2' inputValue='300'/>" + 
            "</entry>";

I am sending an AJAX request as:

$.ajax({
                url: cellUrl,
                type: "PUT",
                contentType: 'application/atom+xml',
                processData: false,
                data: XMLData,
                error: function(XMLHttpRequest, textStatus, errorThrown){
                    alert(errorThrown);
                }, success: function(data, textStatus, XMLHttpRequest){
                    alert("Succeeded");
                }
            });

However, he does not write or show any warnings! What is a problem?

Should I use POST to write? How to do it?

I have a cellURL private key for security. And it looks like a key in my spreadsheet email address.

+3
source share
2 answers

my suggestion

  • check 'key' resourceID should exit
  • , click. ajax iframe.
  • try $.ajax({..., data: $(XMLData),...});
0

- , , :

$.ajax({
        url: cellUrl,
        type: "PUT",
        contentType: 'application/atom+xml',
        processData: false,
        data: XMLData
    }, error: function(XMLHttpRequest, textStatus, errorThrown){
       alert(errorThrown);
    }, success: function(data, textStatus, XMLHttpRequest){
       alert("Succeeded");
    }

);
0

Source: https://habr.com/ru/post/1787134/


All Articles