on the page it grabs the query string and does various processes.
So, what I am really looking for is a better way than this to send out an http request as either a GET or better yet a POST request from keyboard Maestro to go to the url.
Question: is something like this possible using keyboard Maestro? If so how what I set this up - (possibly with JavaScript or something)?
Thank you Vincent. I am starting with a previous page I made using javascript XMLHttpRequest().
I have this script currently working on a web page. So I tried copying it into an Execute JavaScript for Automation Action - is this correct?
It has errors that just display briefly small (notifications) - so I can't really read them.
I have the step set to display results large - but I guess that does not show errors.
Is there a way that I can capture the error so I can read it?
I would prefer to get this XMLHttpRequest() going first over cURL if anyone can help with this - thanks
Also when I try cURL - what KM action would I use to set it up?
I started looking here:
I set the var KMVAR_My_KM_Variable to 'JOE' in earlier step
Then I tried adding this from demo:
EXAMPLE 1
echo | awk -v my_var=4 '{print "My var is " my_var}'
#-->My var is 4
EXAMPLE 2
Display Text “” Briefly
VAR=3
echo | awk -v env_var="$VAR" '{print "The value of VAR is " env_var}'
#-->The value of VAR is 3
USING KM VARIABLES with awk
echo | awk -v env_var="$KMVAR_My_KM_Variable" '{print "The value of My_KM_Variable is: \""env_var"\""}'
#-->The value of My_KM_Variable is: "Text from KM var"
I was trying to do a simple XMLHttpRequest (Post) that works on a web page ok. when I pasted it in KM it gets an error.
Ok I went to the lofts and found this error :
Execute a JavaScript For Automation failed with script error: text-script:141:174: execution error: Error on line 4: ReferenceError: Can't find variable: XMLHttpRequest (-2700) In macro “tests” (while executing Execute JavaScript For Automation).
This is the code test:
var url = 'https://mysite.com/test.php';
var info = {First:"John", Last:"Doe", Company:"TestCo"};
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("POST", url, true);
xhttp.setRequestHeader("Content-type", "application/json;charset=UTF-8");
xhttp.send(JSON.stringify(info));
Awk is a bit of a special case and not a great example of working normally with Keyboard Maestro variables in the shell. I'll expand the wiki later with a section devoted to Bash.
The Keyboard Maestro variable is My_KM_Variable – notKMVAR_My_KM_Variable
The KMVAR_ prefix is necessary to use in the shell.
This example has nothing to do with Keyboard Maestro. It is simply demonstrating using a variable in awk.
I have revised the examples on the wiki and hopefully have improved their clarity. (Work in progress.)
This example too has nothing to do with Keyboard Maestro. It demonstrates using a shell variable in an awk script.
Finally we've come to the point of using the first two examples to work with a Keyboard Maestro variable.
I believe the reason you're not seeing the desired output is as I stated at the beginning:
If not please let me know.
I'll post some more about working with the shell when I have more time.