Welcome Guest, Not a member yet? Register   Sign In
[jQuery/AJAX] Get php function return value
#1

[eluser]Unknown[/eluser]
In my controller content.php is a function called: create_unique_slug.
with the following content:
Code:
public function create_unique_slug($string = 'test')
{
    $slug = url_title($string);
    $slug = strtolower($slug);
    $i = 0;
    $params = array ();
    $params['page_slug'] = $slug;
    if ($this->input->post('id')) {
        $params['id !='] = $this->input->post('id');
    }
    
    while ($this->db->where($params)->get('pages')->num_rows()) {
        if (!preg_match ('/-{1}[0-9]+$/', $slug )) {
            $slug .= '-' . ++$i;
        } else {
            $slug = preg_replace ('/[0-9]+$/', ++$i, $slug );
        }
        $params ['page_slug'] = $slug;
        }
    return $slug;
}

How can i get this return $slug value with jquery?
This doesnt work:
Code:
$.ajax({
  url: './content/create_unique_slug',
  success: function(data) {
    
    alert(data);
  }
});

I would appreciate your help!


Messages In This Thread
[jQuery/AJAX] Get php function return value - by El Forum - 05-20-2012, 09:09 AM
[jQuery/AJAX] Get php function return value - by El Forum - 05-20-2012, 10:13 AM
[jQuery/AJAX] Get php function return value - by El Forum - 05-20-2012, 10:44 AM
[jQuery/AJAX] Get php function return value - by El Forum - 05-22-2012, 01:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB