I am trying to use the following portion of javascript to run a PERL script to return results from a database. The script works when executed from the command line and from a small test HTML web page. However, it does not return any data when I run my ShopSite web page. This script is in my custom page template.
When I put an alert(url) in the customer page template javascript, it shows the correct url and email.
Any help will be greatly appreciated.
############## portion of my page template #################################
<script language = "Javascript">
/**
* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
var emailID = "junk@gmail.com";
function echeck(str) {
var str;
var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
var ldot=str.indexOf(dot);
if (str.indexOf(at)==-1){
alert("Invalid E-mail Address");
return false;
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid E-mail Address");
return false;
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid E-mail Address");
return false;
}
if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail Address");
return false;
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail Address");
return false;
}
if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail Address");
return false;
}
if (str.indexOf(" ")!=-1){
alert("Invalid E-mail Address");
return false;
}
return true;
}
function ValidateForm(){
emailID=document.wishlist00.email.value;
if ((emailID==null)||(emailID=="")){
alert("Please Enter your Email Address");
return false;
}
if (echeck(emailID)==false){
emailID="";
return false;
}
var XMLHttp;
if(navigator.appName == "Microsoft Internet Explorer")
{
XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
XMLHttp = new XMLHttpRequest();
}
var url = "http://yourrcstorecom.fatcow.com/cgi-bin/myWishList01.pl?email="+emailID
XMLHttp.open('GET',url, true);
XMLHttp.onreadystatechange = function()
{
if (XMLHttp.readyState == 4)
{
document.getElementById( 'wishlist01' ).innerHTML = XMLHttp.responseText;
}
}
XMLHttp.send(null);
}
</script>
<table width="650" align="center">
<tbody>
<tr>
<td align="left">
<form name="wishlist00" >
<input type=text name="email" value="">
<input type = button onclick = "return ValidateForm ()" value = "Show Wish List">
</form>
</td>
</tr>
</tbody>
</table>
<div id = "wishlist01">
</div>