This is view file script code function
function getState(val) {
$.ajax({
url: "{{ URL::to('admin/state_change') }}" + "/" + val, //url route
controller in route.php
type: "GET",
dataType: "json",
success: function (data) {
var lid = data.lawid; //getting value from controller
var scn = data.sortname; //getting value from controller
var finlawid = 'L'+scn+'C'+lid; //concatinating
$("#lm_id").val(finlawid); // Lm_id is textbox id
}
});
}
I want to access the lid an scn variable in below function which present in same file
function getStatename(val) {
if (val >= 0) {
// access lid and scn to concatinat more characters and assigned it to lm_id textbox
}
}