Pass parameters when using bookmark URLs?
-
@insaneoctane, I could add the ability to add a URL parameter to the bookmark URL's. Would that work?
Like this:
https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken¶ms=foo
EDIT: I added that capability. Now you can add ¶ms=foo to the end of your bookmark URL to send a parameter of foo to your command. That assumes you've enabled parameters on your command of course.
-
@russ said in Pass parameters when using bookmark URLs?:
https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken¶ms=foo
Russ, that is fantastic that you could add that capability so quickly! I tried the API too and I'm getting the same CORS error. I'm SO not that knowledgeable with CORS/networks stuff, but I think the CORS error is because my javascript isn't being allowed to GET the bookmark (or API) without a proper header from triggercmd.com domain???? Have you seen or dealt with this before?
Here's the errors I'm seeing in the dev console from chrome:
Access to fetch at 'https://www.triggercmd.com/trigger/bookmark?token=XXXXX¶ms=75' from origin 'http://127.0.0.1' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains the invalid value ''. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
XXXX.html:74 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.triggercmd.com/trigger/bookmark?token=XXXXX¶ms=75 with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
-
@insaneoctane, I used this web page to test, and I wasn't able to reproduce the error.
Can you send me something that would help me reproduce it?
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.get("https://www.triggercmd.com/trigger/bookmark?token=(bookmarkToken)", { params: "Donald Duck", }, function(data,status){ alert("Data: " + data + "\nStatus: " + status); }); }); }); </script> </head> <body> <button>Send an HTTP GET request to a page and get the result back</button> </body> </html>
-
@Russ,
Just curious if you ran your script from triggercmd.com domain? -
@insaneoctane, no I served that page from w3schools. Please try it here:
https://www.w3schools.com/code/tryit.asp?filename=FX706MSHLN0A
-
@russ
I can't thank you enough for your time on this issue!
I ran the snippet from the W3 site you linked to, clicked the button and got nothing. To see what was happening (I'm in Chrome) I hit F12 and opened up the developers console and saw CORS errors. Here's a snip from the console:Access to XMLHttpRequest at 'https://www.triggercmd.com/trigger/bookmark?token=(youBookmarktoken)¶ms=Donald Duck' from origin 'https://tryit.w3schools.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains the invalid value ''.
VM38:1 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.triggercmd.com/trigger/bookmark?token=(youBookmarktoken)¶ms=Donald Duck with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
(anonymous) @ VM38:1
send @ jquery.min.js:2
ajax @ jquery.min.js:2
w.(anonymous function) @ jquery.min.js:2
(anonymous) @ tryit_view.php?x=0.3774193121824916:8
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2 -
@insaneoctane, I see the same thing in the developers console, but it does actually run Notepad with Donald Duck as the parameter if I give it an actual bookmark token.
Did you try that?
-
@russ,
I did try it after you asked and yes, it working even though there are CORS errors in the console. Once I saw those, I quit troubleshooting, but it appears it is working. Thanks again for your efforts and a great app! -
Can I add more than one parameter and, if yes, how is the syntax ?
-
@bugtrapper, you should be able to pass multiple parameters by putting a space between them, or a %20 between them, like this:
https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken¶ms=foo bar
or
https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken¶ms=foo&20bar
-
Thank you