admin管理员组

文章数量:1389903

Hope you’re doing well!

If you could, I’d like help with this: I’m very new to javascript, and have a question. How do I trigger a webhook URL by javascript (without loading the page)? In this case, the webhook responds “silently”, and is used just to kick off Zapier events. All that really needs to happen is to trigger the URL on pageload through javacsript (the javascript containing the webhook trigger). As long as the URL is triggered, that’s really all I’m looking for.

Really Appreciate your help. : )

Thanks! Vince

I've tried the window.location parameter, but it doesn't seem to be triggering the webhook URL.

<script>
window.location = '[webhook url here]'
<script>

Actual Results: Code is not triggering the webhook URL on pageload.

Thanks for your help! - Vince

Hope you’re doing well!

If you could, I’d like help with this: I’m very new to javascript, and have a question. How do I trigger a webhook URL by javascript (without loading the page)? In this case, the webhook responds “silently”, and is used just to kick off Zapier events. All that really needs to happen is to trigger the URL on pageload through javacsript (the javascript containing the webhook trigger). As long as the URL is triggered, that’s really all I’m looking for.

Really Appreciate your help. : )

Thanks! Vince

I've tried the window.location parameter, but it doesn't seem to be triggering the webhook URL.

<script>
window.location = '[webhook url here]'
<script>

Actual Results: Code is not triggering the webhook URL on pageload.

Thanks for your help! - Vince

Share Improve this question asked Aug 9, 2019 at 16:04 VinceJVinceJ 812 gold badges2 silver badges5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You can send a request to a URL with the fetch API.

fetch('http://example.');

This should be enough to 'trigger' (load) the URL and it won't make the browser actually visit the page, just send a request to it.

The fetch call returns a promise that resolves to a response. So if you want to log the response you get you can do it like this: *Example taken from MDN. In this example the fetch call returns JSON data.

fetch('http://example./movies.json')
  .then(function(response) {
    return response.json();
  })
  .then(function(myJson) {
    console.log(JSON.stringify(myJson));
  });

You can read more about how to use it here:

https://developer.mozilla/en-US/docs/Web/API/Fetch_API/Using_Fetch

本文标签: jqueryHow to Trigger Webhook With Javascript SnippetStack Overflow