i have button in javascript, when i click ,it calls a CGI perl script and returns a download popup to me.
Prob-->
When javascript calling the script it starts a new thread redirecting to perl script and end. So i m not getting any action or response inside javascript.

What I want--->
After finishing perl script it will show some message in javascript that perl script finished.

Plz helh me out .

If it were me, I'd use jquery to make an AJAX request to your perl script URL. Look into jquery and AJAX. You don't have to return XML BTW, you can just return a value and have jquery parse it for you.

This is really more of a java script question than a perl question. Include the jquery library at the top of your page and make the request WITHIN the browser.

You have to be mindful of browser differences (especially IE 7).

Hi mitchem,

Thanks for reply.
Prob is i am calling the perl script from javascript using
window.location("perl script + passing values")
[ This is actually a call on clicking a button]

Perl script starts a new thread to a device to get the data and if successful then it prompts for download popup.

Perl is written using CGI script.

What i wnt is , if someone in between click on the button twice (consecutive) then he/she should see some msg like server is processing and no more thread or perl should be created.

Your problem is the WAY you're launching the CGI perl script. I am only going to do this once and it's not perl-related, but here is some jquery code that you can use as an example to get data from the CGI script and disable the button after clicking it ONCE.

<html><head>
 <script type="text/javascript" src="./jquery.js"></script>

<script type="text/javascript">
$(document).ready(function(){

        $("#butt1").click(function(){
						  
              	$("#butt1").hide();
                // now, submit the form. But I'd still do it with AJAX because you can return a value to this script     
                $.ajax({
   				url: "/cgi-bin/perlscript.cgi",
				dataType: "text",
							
			success: function(data){
		             var rows = data.split("\n");
		             var row1=rows[0];
			     alert("I got back"+row1);
			}
            		}); // End AJAX
            		//then here, do whatever you need to do with the return value. 
	});

});
</script>
</head><body>
<form action="/cgi-bin/perl.cgi" method=get name="form1" id="form1" target="_blank">
<input type="button" name="butt1" value="click me" id="butt1">
</body>
</form></html>

It is just an HTML page with jQuery being used for the Javascript. You're problem is not really perl-related. If you wish to get more information, perhaps check out the Javascript forum.

Edited 6 Years Ago by mitchems: n/a

This article has been dead for over six months. Start a new discussion instead.