Code To Fetch cities in Alphabetical order with jquery Ajax ---
$(document).ready(function(){
$(".country").change(function() {
setTimeout(
function()
{
var options = $('select.city option');
var arr = options.map(function(_, o) {
return {
t: $(o).text(),
v: o.value
};
}).get();
arr.sort(function(o1, o2) {
return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0;
});
options.each(function(i, o) {
console.log(i);
o.value = arr[i].v;
$(o).text(arr[i].t);
});
}, 1000);
});
-------------------------------------
$("#input_1_10").change(function() {
//get the selected value
var categ = $("#input_1_10 option:selected").text();
//var state = this.value;
var city = $("#input_1_21").val();
//var category = $("#input_1_10").val();
//var categ = $("#input_1_10 option:selected").text();
//alert(categ+city);
$.ajax({
url: 'http://therapy.leadingedgeinfosolutions.com/chkstatus.php',
type: 'POST',
data: {city : city,category: category},
success: function(data) {
if( data == 'no')
{
$("#lightf2").show();
$("#fade").show();
$("#input_132").val(state);
$("#input_98").val(categ);
return false;
}
}
});
//make the ajax call
});
});
</script>
$(document).ready(function(){
$(".country").change(function() {
setTimeout(
function()
{
var options = $('select.city option');
var arr = options.map(function(_, o) {
return {
t: $(o).text(),
v: o.value
};
}).get();
arr.sort(function(o1, o2) {
return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0;
});
options.each(function(i, o) {
console.log(i);
o.value = arr[i].v;
$(o).text(arr[i].t);
});
}, 1000);
});
-------------------------------------
$("#input_1_10").change(function() {
//get the selected value
var categ = $("#input_1_10 option:selected").text();
//var state = this.value;
var city = $("#input_1_21").val();
//var category = $("#input_1_10").val();
//var categ = $("#input_1_10 option:selected").text();
//alert(categ+city);
$.ajax({
url: 'http://therapy.leadingedgeinfosolutions.com/chkstatus.php',
type: 'POST',
data: {city : city,category: category},
success: function(data) {
if( data == 'no')
{
$("#lightf2").show();
$("#fade").show();
$("#input_132").val(state);
$("#input_98").val(categ);
return false;
}
}
});
//make the ajax call
});
});
</script>
No comments:
Post a Comment