[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!