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 //console.log(response); 23 if (response.length > 0) { 24 $(form).find("select.state_auto").html('<option value="0" data-id="0">Select State</option>'); 25 for (i = 0; i < response.length; i++) { 26 var st_id = response[i]['id']; 27 var st_name = response[i]['name']; 28 var opt = "<option data-id='" + st_id + "' value='" + st_name + "'>" + st_name + "</option>"; 29 $(form).find("select.state_auto").append(opt); 30 } 31 } 32 else { 33 $(form).find("select.state_auto").html(''); 34 var opt = "<option value='0'>State List Not Found</option>"; 35 $(form).find("select.state_auto").append(opt); 36 console.log("State List Not Found"); 37 } 38 } 39 }); 40 41 } 42 }); 43 44 /* --------------------- GET CITIES ------------------------ */ 45 46 $("select.state_auto").change(function () { 47 var form = (this).closest("form"); 48 //console.log(form); 49 if ($(this).closest("form").find("select.city_auto").length > 0) { 50 var sid = $(form).find("select.state_auto").children("option:selected").attr('data-id'); 51 //console.log(sid); 52 $(form).find("select.city_auto").html('<option value="0001" data-id="0001">Loading...</option>'); 53 if (sid == '0') { 54 $(form).find("select.city_auto").html('<option value="0" data-id="0">Select City</option>'); 55 return false; 56 //return rv; 57 } 58 jQuery.ajax({ 59 url: tc_csca_auto_ajax.ajax_url, 60 type: 'post', 61 dataType: "json", 62 data: { action: "tc_csca_get_cities", nonce_ajax: tc_csca_auto_ajax.nonce, sid: sid }, 63 success: function (response) { 64 if (response.length > 0) { 65 $(form).find("select.city_auto").html('<option value="0" data-id="0">Select City</option>'); 66 for (i = 0; i < response.length; i++) { 67 var ct_id = response[i]['id']; 68 var ct_name = response[i]['name']; 69 var opt = "<option value='" + ct_name + "' data-id='" + ct_id + "'>" + ct_name + "</option>"; 70 $(form).find("select.city_auto").append(opt); 71 } 72 } else { 73 $(form).find("select.city_auto").html(''); 74 var opt = "<option value='0'>City List Not Found</option>"; 75 $(form).find("select.city_auto").append(opt); 76 console.log("City List Not Found"); 77 } 78 } 79 }); 80 } 81 }); 82});
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.