How to send multiple ajax request and process the multiple request one after the other and display returned data in respected drop down list
Below is the ajax code to perform the subjected action but it is implemented in a manner of elaboration instead of do it with simple one.
Here implemented separate code for each ajax request and response.
please see the below code:
$(document).ready(function(){ $("#country").change(function(){ var country=$("#country").val(); $.ajax({ type:"post", url:"getstate.php", data:'typeId='+country, success:function(data){ $("#state").html(data); } }); }); }); $(document).ready(function(){ $("#district").change(function(){ var district=$("#district").val(); $.ajax({ type:"post", url:"getward.php", data:'typeId='+district, success:function(data){ $("#ward").html(data); } }); }); }); Country : error_reporting(E_ALL); ini_set('display_errors', 1); include "dbconfig.php"; $result=sqlsrv_query($conn,"SELECT [CountryId],[Country] from toilet_Country order by Country"); while($country=sqlsrv_fetch_array($result)){ echo ""; } ?>
State :
District :
Ward :
Slum :
And i have written code in separate files to retrieve country,state,district information from database.
I am unaware of these ajax call request and response and looking for advise how can i make this code portable.
Thanks in advance.
Nanhe SiddiquePosted May 18, 2015, 4:35 AM