In other site, i have an ajax routine that sends the parameters (via
get) and is expected to capture the resulting page, but is not
working. If I try with a static page, there is not problem, only when
calling that CGI.
I try changing the content-type (html, text) and specifing the status
header (200 ok) but my ajax routine receive an 0 status code. I tested
the CGI directly via browser and it works fine
Any idea where is going this?
If this help, here is my ajax routine:
function ShowInstallInfo (int_value)
{
var ajax_this;
if (window.XMLHttpRequest) { ajax_this = new XMLHttpRequest(); }
else { ajax_this = new ActiveXObject("Microsoft.XMLHTTP"); }
ajax_this.onreadystatechange = function ()
{ if (ajax_this.readyState==4 || ajax_this.readyState=="complete")
{ alert("Results: "+ajax_this.status+" text:"+ajax_this.responseText); }
};
// This URI works (test): 'http://www.hunlock.com/examples/notajax.html';
// This URI DOES NOT works (mine):
'http://keys.siteupsoftware.com/cgi-bin/install_verify.cgi?value='+int_value;
var myurl = 'http://www.hunlock.com/examples/notajax.html';
ajax_this.open("GET", myurl, true);
ajax_this.send(null);
}
Is the `onreadystatechange' handler called when readyState == 3?
--
Alexander Krasnorutsky.
> -----Original Message-----
> From: bu...@alejandro.ceballos.info
> [mailto:bu...@alejandro.ceballos.info]
> Sent: 27 November 2009 13:59
> To: beginn...@perl.org
> Subject: Loading results (via ajax) from a CGI
>
> Any idea where is going this?
>
>
> If this help, here is my ajax routine:
>
> function ShowInstallInfo (int_value)
> {
> var ajax_this;
> if (window.XMLHttpRequest) { ajax_this = new XMLHttpRequest(); }
> else { ajax_this = new ActiveXObject("Microsoft.XMLHTTP"); }
> ajax_this.onreadystatechange = function ()
Take out the if clause and see what you get.
> { if (ajax_this.readyState==4 ||
ajax_this.readyState=="complete")
> { alert("Results: "+ajax_this.status+"
> text:"+ajax_this.responseText); }
> };
// { if (ajax_this.readyState==4 || ajax_this.readyState=="complete")
{ alert("Results: "+ajax_this.status+"
text:"+ajax_this.responseText); }
// };
Good luck,
Dp.
The may be a problem with your headers. What i mean is, is the browser
(wrongly) caching the page you request?
Try setting the correct headers. Also, you might add an ever-changing
dummy value to your request to trick the browser into thinking this is a
new, non-cached page.
You have
var myurl = 'http://server/script.cgi?value='+int_value;
change to:
var myurl = 'http://server/script.cgi?value='+int_value + '&dummyvalue='
+ now.getTime();
LG
Rene