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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.