I am bumfuzzled by what "should" be a simple thing. I'm using
prototype 1.6.1. The server side is working. The chkCardNum function
gets called...but nothing fires.
<script type="text/javascript">
<!--
function chkCardNum() {
var notice = $('notice');
notice.update('Checking card number');
new Ajax.Request('
https://www.somesite/cgi-bin/ajax.cgi',
{
method: 'post',
onSuccess: function(transport) {
if (transport.responseText.match(/OK/)) {
notice.update('Card number passes').setStyle({ background:
'#dfd' });
}
else if (transport.responseText.match(/N0/)) {
notice.update('The card number provided seems to have an
error.').setStyle({ background: '#fdd' });
}
},
onFailure: function(transport) {
alert('Something went wrong');
}
});
}
//-->
</script>
</head>
<body>
<div>
<form name="testform" method="post" action="#">
<p>Number: <input align="bottom" id="cardnum" name="cardnum"
type="text" size="20" value="" class="monospc" onchange="chkCardNum
()"></p>
<p id='notice'></p>
</form>
</div>
</body>
</html>
On the server end, this is all I'm using for this test.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print 'OK';
Why won't it work?