My goal is to get some of the value from ajax data to assign in php variable. As you can see the ajax code below, i could pass the value through a class (edit_id
). How to put the value from the textbox to a php variable?
Ajax
$.ajax({
type: 'POST',
url: "{{ URL::route('test') }}",
headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}' },
data: { "camp_id" : camp_id },
success: function(data){
if(data.data.success){
$('#edit_id').val(data.data.success.id);
$('#edit_desc').val(data.data.success.description);
console.log(data.data.success.id); // this will output the id eg. 1
console.log(data.data.success.description); // this will output the description eg. hello world
}
}
});
View
<input type="text" class="form-control" id="edit_id" name="id"> //will diplay textbox with value