View Full Version : Ajax Function Missing I think, please help

Jenny Dithe
09-11-2010, 08:37 AM

I am trying to work out how to do an external ajax page.

What I am doing is I have a selection of buttons and if they are clicked I want to call my external ajax page which will then call the information.

So on my webpage I have the below:

<script type="text/javascript" src="myajax.js"></script>
<input type="button" name="MyCar" value="My Car" onclick="ShowMyCars()" />
<input type="button" name="XCar" value="X Car" onclick="ShowXCars()" />
<input type="button" name="YCar" value="Y Car" onclick="ShowYCars()" />
<br />
<br />
<div id="txtHintMyCar"></div>

So as far as I can tell I may be missing a function to call my AJAX page.

The myajax.js code is

var xmlhttp

function showMyCars()
if (str. length==0)
if (xmlhttp==null)
alert ("Your browser does not support XMLHTTP!");
var url="getMyCars.php";

function stateChanged()
if (xmlhttp.readyState==4)
document.getElementById("txtHintMyCar").innerHTML= xmlhttp.responseText;

function Get XmlHttpObject()
if (window.XMLHTTPRequest)
return new XMLHttpRequest();
if (window.ActiveObject)
return new ActiveXObject("Microsoft.XMLHTTP");
return null;

I guess the problems I have at this stage are:
1. Do I need a call function to my ajax page and if so what?
2. Do I have the correct scripts on the right pages?
3. Is there anything else I am doing wrong which I should be aware?

Needless to say nothing is happening at the moment.

Any assistance would be great.


Jenny Dithe
09-11-2010, 11:40 AM
I forget to add that I have extra cols in the table which get filled in later

09-12-2010, 11:02 PM
Seems that you are trying to use ajax, with 'GET' method instead of 'POST'.
This ref might help: http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp

See which method your getMyCars.php uses to read params.


Jenny Dithe
09-13-2010, 06:01 AM
Thank you. Important information.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum