AJAX Request Through Weebly

I have been using Weebly along with AirTable and I need to dynamically write data to AirTable based on Weebly events. So far the GET requests for AirTable API work and the PATCH requests come back as completed, however the PATCH requests do not actually update the AirTable values as they are supposed to. This code works on all other sites including JSFiddle and any other website that I could add the code into the chrome inspect console. The code, however, fails when used on my personal Weebly site or any other Weebly through the inspect console as well. This makes me believe that maybe the issue lies in a setting in Weebly?

Here is the code...

var settings = {
"url": "https://api.airtable.com/v0/{appid}/Table1",
"method": "PATCH",
"timeout": 0,
"headers": {
"Content-type": "application/json",
"Authorization": "Bearer XXX"
},
"data": JSON.stringify({
"records": [
{
"id": "{recID}",
"fields": {
"Name": "George"
}
}
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});

1,582 Views
Message 1 of 4
Report
1 Best Answer
Square

Best Answer

Hi, @Egauon. If I had to guess, I'd say it's because the $ is getting used by any Javascript libraries, so it's not doing anything. You might want to try something like jQuery.ajax(settings)... and see if that works.

View Best Answer >

1,550 Views
Message 5 of 4
Report
3 REPLIES 3
Square

Best Answer

Hi, @Egauon. If I had to guess, I'd say it's because the $ is getting used by any Javascript libraries, so it's not doing anything. You might want to try something like jQuery.ajax(settings)... and see if that works.

1,551 Views
Message 5 of 4
Report

Thanks bro! That was 100% the reason. I completely forgot I asked this question and I used your fix and $.noConflict() to fix! Thank you so much for answering!

1,522 Views
Message 5 of 4
Report
Square

Nice! Glad to hear that resolved it for you. Smiley Happy

1,511 Views
Message 5 of 4
Report
This thread has been archived and locked. Please start a new thread if you would like to continue the conversation.