Here we have used data-type instead of data-id. However we can use anything other than this.
Button to click
<a href="javascript:void(0)" data-type="31" onclick="demo(this)" >Verify Image</a> ||
<a href="javascript:void(0)" data-type="30" onclick="demo(this)" >Unverify Image</a>
JavaScript Code
<script>
function demo(identifier)
{
var verifyType = $(identifier).data('type');
$user_id = {{$user->id}};
var a_url = "{{ route('superadmin.ajax.verifyUser','rrr') }}";
var url = a_url.replace('rrr',$user_id);
$.ajax({
type:'POST',
url:url,
data:{'_token':"{{ csrf_token() }}",'verify_id':verifyType},
success:function(res,responseText,jqxhr){
window.location.reload(true);
// $(".modal-content .imageverified-script").html(res.image_verified_at);
},
error:function(res,responseText,jqxhr,errorStatus){
console.error(res.b);
}
});
}
</script>
NOTE:
In case of Select option having data-id , then you can get the value using following:==>
var id = $('option:selected',this).attr('data-id');