Reputation: 7930
How can I make a cgi script be executed when a javascript function is called? Currently I am using a small iframe and loading the cgi script there, but it does not seem to be working. here is a snippet of code:
function back()
{
document.getElementById("hidden").src="scripts/backImage.cgi";//execute background script
document.getElementById("scan").src="scripts/getImage.cgi";//reload the display iframe
}
Upvotes: 4
Views: 16813
Reputation: 2295
If you can use a JS library like jquery take a look at https://stackoverflow.com/a/861808/211097.
Code snippet from that answer:
$.ajax({
type:'get',
url:'http://mysite.com/mywebservice',
success:function(data) {
alert(data);
}
});
Upvotes: 0
Reputation: 37781
You can use jQuery.ajax, or the shorthand:
jQuery.get("scripts/backImage.cgi");
Upvotes: 4
Reputation: 143329
You can use XMLHttpRequest to trigger access to your cgi script.
Upvotes: 5