Jump to content

AJAX Issue


glenelkins

Recommended Posts

Hi

 

I have an application that has 3 <select> drop downs

 

Like so:

 

Store

Order

Driver

 

You select a store which runs the following javascript functions onclick: ( onclick="ShowOrders ( store_id_here );" )

 

function ShowOrders ( store_id ) {

	req_obj.open ( 'get', 'ajax.php?action=orders&store_id=' + store_id );

	req_obj.onreadystatechange = processOrders;

	req_obj.send(null);


}

function processOrders() {

	if ( req_obj.readyState == 4 ) {

		var response = req_obj.responseText;

		document.getElementById ( "order_select" ).innerHTML = response;

	}

}

 

This runs fine, and shows all the orders within the orders drop down for that store. Perfectly fine AJAX working!

 

But, if i then run ShowDrivers() directly after the ShowOrders, the orders box is not filled, but rather vanishes from the page, and the drivers drop down does not change at all. Here is the ShowDrivers function :

 

function ShowDrivers ( store_id ) {

	req_obj.open ( 'get', 'ajax.php?action=drivers&store_id=' + store_id );

	req_obj.onreadystatechange = processDrivers;

	req_obj.send(null);

}

function processDrivers() {

	if ( req_obj.readyState == 4 ) {

		var response = req_obj.responseText;

		document.getElementById ( "driver_select" ).innerHTML = response;

	}

}

 

STRANGE!

 

Link to comment
https://forums.phpfreaks.com/topic/107067-ajax-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.