Welcome Guest, Not a member yet? Register   Sign In
Need Quick Ajax Help
#6

[eluser]RMinor[/eluser]
[quote author="CroNiX" date="1337569002"]With ajax, you need to echo out the response. Returning it does nothing as you aren't returning php to a php function.

Also, you are sending the data via POST, so in your controller, you need to get the value that you are going to be searching for via POST.

The javascript...
Code:
data: {zip: input_zip},  //set the zip post variable

Then in your
Code:
public function getCity()
{
$zip_code = $this->input->post('zip', TRUE); //get the zip from post
$sql = "SELECT city_name FROM city WHERE city_zip = ?";
$query = $this->db->query($sql, array($zip_code));
$result = $query->row_array();
echo $result['city_name'];  //echo, not return
}
[/quote]


I can't believe I overlooked that. Such a dumb error on my part. Thank you for your reply.


Messages In This Thread
Need Quick Ajax Help - by El Forum - 05-20-2012, 02:48 PM
Need Quick Ajax Help - by El Forum - 05-20-2012, 03:34 PM
Need Quick Ajax Help - by El Forum - 05-20-2012, 03:39 PM
Need Quick Ajax Help - by El Forum - 05-20-2012, 07:53 PM
Need Quick Ajax Help - by El Forum - 05-20-2012, 07:56 PM
Need Quick Ajax Help - by El Forum - 05-21-2012, 08:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB