Hi,
I have been trying to output some info about a city limit based on an entered zipcode using AJAX, and it's just not working at all. I've tried everything, it's either displaying "null" or not displaying anything or just a Fatal Error :?
Please help. Thank you!
Form: http://givsmart.com/index.php?option=com_chronoforms&chronoform=DonationsFormSM-Copy
JavaScript Code
AJAX custom Code Action:
I have been trying to output some info about a city limit based on an entered zipcode using AJAX, and it's just not working at all. I've tried everything, it's either displaying "null" or not displaying anything or just a Fatal Error :?
Please help. Thank you!
Form: http://givsmart.com/index.php?option=com_chronoforms&chronoform=DonationsFormSM-Copy
JavaScript Code
window.addEvent('domready', function()
{
/// CITY LIMIT ////
limitInfo=$('limitInfo');
var url2 = 'index.php?option=com_chronoforms&tmpl=component&chronoform=DonationsFormSM-Copy&event=ajaxCitylimit&format=raw';
//Ajax CityLimit check
var Zipcode2 = $('Zipcode');
Zipcode2.addEvent('blur', function(e)
{
var value2 = Zipcode2.value.trim();
var request2 = new Request(
{
method: 'post',
url: url2,
data: { 'Zipcode2' : value2 },
onRequest: function() { limitInfo.innerHTML="Looking...";
},
onComplete: function (r) {
limitInfo.innerHTML="Attention! " +r + "!!!";
}
}).send();
});
});
AJAX custom Code Action:
<?php
// get the query info
$Zipcode2;
$Zipcode2 = JRequest::getString('Zipcode2', '', 'post');
$Zipcode2 = trim($Zipcode2);
$db2 =& JFactory::getDBO();
$query2 = "
SELECT `City`,`Zip`
FROM `#__chronoforms_data_CityLimit`
WHERE `Zip`= ".$db->quote($Zipcode2).";
";
$db2->setQuery($query2);
$data2 = $db2->loadResult;
echo "$data2";
?>