Welcome Guest, Not a member yet? Register   Sign In
How to check existing data with jquery validation library with codeigniter 4 csrf?
#4

(01-16-2021, 12:39 AM)onebuyu Wrote:  Thank you very much. I corrected  with your suggestion. but my problem now is  how I can update csrf on jqery remote object " remote:{ data:{} } "?

I don't understand the essence of the problem.
I don't know how the library works, but I assume that you already have some code that overwrites the csrf hash.

Code:
complete: function(data){
   $('input[name="csrf_hash_name"]').val(data.csrf);
}
and the value of the csrf_hash_name key in the "data" object is computed on every request.

Just send data
PHP Code:
return $this->response->setJSON([
    'status' => ! (bool) $count// convert number to boolean and invert ( 0 = true; > 0 = false)
    'csrf' => csrf_hash()
]); 


Receiving data
Code:
complete: function(data){
    $('input[name="csrf_hash_name"]').val(data.csrf);
    return data.status;
}
Reply


Messages In This Thread
RE: How to check existing data with jquery validation library with codeigniter 4 csrf? - by iRedds - 01-16-2021, 03:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB