1/* --------------------- GET STATES FROM COUNTRY ID ------------------------ */ 2jQuery(function ($) { 3 //console.log("test"); 4 $("select.country_auto").change(function () { 5 var form = (this).closest("form"); 6 //console.log(form); 7 if ($(this).closest("form").find("select.state_auto").length > 0) { 8 var cnt = $(form).find("select.country_auto").children("option:selected").attr('data-id'); 9 //console.log(cnt); 10 $(form).find("select.state_auto").html('<option value="0001" data-id="0001">Loading...</option>'); 11 $(form).find("select.city_auto").html('<option value="0" data-id="0">Select City</option>'); 12 if (cnt == '0') { 13 $(form).find("select.state_auto").html('<option value="0">Select State</option>'); 14 return false; 15 } 16 jQuery.ajax({ 17 url: tc_csca_auto_ajax.ajax_url, 18 type: 'post', 19 dataType: "json", 20 data: { action: "tc_csca_get_states", nonce_ajax: tc_csca_auto_ajax.nonce, cnt: cnt }, 21 success: function (response) { 22 if (response.length > 0) { 23 $(form).find("select.state_auto").html('<option value="0" data-id="0">Select State</option>'); 24 for (i = 0; i < response.length; i++) { 25 var st_id = response[i]['id']; 26 var st_name = response[i]['name']; 27 var opt = "<option data-id='" + st_id + "' value='" + st_name + "'>" + st_name + "</option>"; 28 $(form).find("select.state_auto").append(opt); 29 } 30 } 31 else { 32 $(form).find("select.state_auto").html(''); 33 var opt = "<option value='0'>State List Not Found</option>"; 34 $(form).find("select.state_auto").append(opt); 35 console.log("State List Not Found"); 36 } 37 } 38 }); 39 40 } 41 }); 42 43 /* --------------------- GET CITIES ------------------------ */ 44 45 $("select.state_auto").change(function () { 46 var form = (this).closest("form"); 47 //console.log(form); 48 if ($(this).closest("form").find("select.city_auto").length > 0) { 49 var sid = $(form).find("select.state_auto").children("option:selected").attr('data-id'); 50 //console.log(sid); 51 $(form).find("select.city_auto").html('<option value="0001" data-id="0001">Loading...</option>'); 52 if (sid == '0') { 53 $(form).find("select.city_auto").html('<option value="0" data-id="0">Select City</option>'); 54 return false; 55 //return rv; 56 } 57 jQuery.ajax({ 58 url: tc_csca_auto_ajax.ajax_url, 59 type: 'post', 60 dataType: "json", 61 data: { action: "tc_csca_get_cities", nonce_ajax: tc_csca_auto_ajax.nonce, sid: sid }, 62 success: function (response) { 63 if (response.length > 0) { 64 $(form).find("select.city_auto").html('<option value="0" data-id="0">Select City</option>'); 65 for (i = 0; i < response.length; i++) { 66 var ct_id = response[i]['id']; 67 var ct_name = response[i]['name']; 68 var opt = "<option value='" + ct_name + "' data-id='" + ct_id + "'>" + ct_name + "</option>"; 69 $(form).find("select.city_auto").append(opt); 70 } 71 } else { 72 $(form).find("select.city_auto").html(''); 73 var opt = "<option value='0'>City List Not Found</option>"; 74 $(form).find("select.city_auto").append(opt); 75 console.log("City List Not Found"); 76 } 77 } 78 }); 79 } 80 }); 81});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.