Hi, I’m new to Javascript and Ajax, and I keep getting an error on a line in my html where I am trying to execute a function.
Here’s the html line :
<input type=”button” onclick=”ajaxFunction();” value=”Search”>
I have tried it with ‘ quotes, without ; even copy and pasted the ajaxFunction()
I’m pretty sure that java is enabled in my browser as I have gone through the settings and have jre/jdk installed.
But I keep getting this error :
Line: 78
Char: 1
Error: Object expected
Code: 0
URL: the url of the page
Here’s my Javascript :
[code]
<script type=”text/javascript/” language=”javascript”>
// Browser Support code
function ajaxFunction()
{
var ajaxRequest; // The variable that makes Ajax possible!
try {
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try {
ajaxRequest = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch (e) {
try {
ajaxRequest = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch (e){
// Something went wrong
alert(“Your browser broke!”);
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById(‘ajaxDiv’);
ajaxDisplay.innerHTML = ajaxRequest.responseText;
// document.getElementById(‘customer’).value = ajaxRequest.responseText
// array ajaxDisplay = document.getElementById(‘customer’);
// ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var customer = document.getElementById(‘customer’).value;
var queryString = “?customer=” + customer;
ajaxRequest.open(“GET”, “ajaxCust.php” + queryString, true);
ajaxRequest.send(null);
}
Could it be that the data is not being set to be sent? Or I don’t know, any pointers?
Thanks in advance