Skip to content
Advertisement

how do pass $res from codeigniter model to my ajax function in view?

I want to verify user details from the table.My model looks like this:

JavaScript

Here, when I try to echo $res, it does not bring any information on my view. My Controller looks:

JavaScript

This is where I want to pass the results from Model as an object and then help me to direct which page to load. My function in view is:

JavaScript

Advertisement

Answer

You’re doing everything right, but when you echo true or false it cannot be read by ajax response. Instead of setting $res to true false, set it to 1 and 0.

JavaScript

jQuery Code :

data variable of success callback will have your $res. You don’t need to pass it explicitly.

If $res is 1 it will redirect to “home/home” else to “home/load_register”

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement