Although I have no prior experience with Ajax, I am in need of some guidance to create a simple Chrome extension. Despite searching online, I have not been able to find much information on this topic, which I believe should be straightforward.
Request URL:
Request Method: POST
Request Payload:
{amount: 1, user_id: 12345678}
When calling the URL automatically from the website's network panel, certain adjustments need to be made manually, such as changing the token and url values to real data.
In my plan to mix AJAX and JS to call this URL, I intend to use variables for both the TOKEN_VALUE and user_id/amount parameters. However, I lack the know-how on how to execute this call and set the request payload correctly for the site to function as desired.
Your assistance would be greatly appreciated. Here is the code snippet that I have tried so far but did not work:
var request=new XMLHttpRequest;
request.open("POST","https://URL_OF_THE_WEBSITE/v1/send?token=TOKEN_VALUE"),request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"),request.Payload("user_id=12345678&amount=5");
I attempted to replicate an example I found online, but it proved unsuccessful. Therefore, I kindly ask for someone to explain how this process works and guide me on adjusting the necessary arguments. Thank you.