I am working on Ajax.i have multiple select box now i want recall same page again and again but problem is that we have lots sql query.with the of if condition i select query according to my need.now i want check like if ($_POST['field'] contain state or region ); ajax part:-
$('#country').change(function()
{
var id=$("#country").val();
var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: "ajax_centre.php",
data: {state:dataString,field:'state'},
cache: false,
success: function(html)
{
$("#state").html(html);
}
});
});
$('#state').change(function()
{
var state_id=$('#state').val();
var country_id=$('#country').val();
var dataString = 'state_id='+ state_id;
var country_id = 'country_id='+ country_id;
$.ajax
({
type: "POST",
url: "ajax_centre.php",
data: {country:country_id,state:dataString,field:'region'},
cache: false,
success: function(html)
{
$("#region").html(html);
}
});
});
in upper part i pass field:state and field:region now i want to select my on behalf of that //ajax_centre.php:-
if($_POST['field']='state')
{
//execute query
}
if($_POST['field']='region')
{
//execute query
}
is this possible i know isset() but i have to differentiate each other
i finally i find the bug problem exist in passing post value correct script:-
$('#country').change(function()
{
var id=$("#country").val();
//var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: "ajax_centre.php",
data: {id:id,field:'state'},
cache: false,
success: function(html)
{
$("#state").html(html);
}
});
});
$('#state').change(function()
{
var state_id=$('#state').val();
var country_id=$('#country').val();
//var dataString = 'state_id='+ state_id;
//var country_id = 'country_id='+ country_id;
$.ajax
({
type: "POST",
url: "ajax_centre.php",
data: {con_id:country_id,sta_id:state_id,field:'region'},
cache: false,
success: function(html)
{
$("#region").html(html);
}
});
});
one think i got both operator work in my case "==" and "===".