02-01-2010, 11:37 AM
[eluser]chefnelone[/eluser]
I'm using ajax request (with jquery). Until now everything went fine.
But I have a problem when I use the URI class.
When using segments in the url the ajax request doesn't work.
If I run this code there's no problem
in controller site.php
in the view views/backend/products.php
and the js which fire the request:
I load the page at: http://locallhost/ci/site/products/
EVETHING WORKS FINE
But if I change this:
for this:(so that I can pass the id in the url)
And load the page at: I load the page at: http://locallhost/ci/site/products/10
I doesn't work.
I don't know how to solve it BUT I know the problem is JUST this line.
I'm using ajax request (with jquery). Until now everything went fine.
But I have a problem when I use the URI class.
When using segments in the url the ajax request doesn't work.
If I run this code there's no problem
in controller site.php
Code:
function products(){
$data['product_id'] = '10';
//CALL A MODEL AND FETCH PRODUCT RELATED TO $data['product_id']
$data['query'] = $this->get_product_model($data['product_id']);
$this->load->view('backend/products', $data);
}
function update_product(){
$data = ($_POST);
$data = $this->update_product_model($data);
}
in the view views/backend/products.php
Code:
<form class="updateProduct" action="" method="post">
<input name="product_name" type="text" size="60" />
<button id="saveButton" type="submit" >Save</button>
</form>
Code:
$(document).ready(function() {
$('.updateProduct').live('submit',function(eve) {
eve.preventDefault();
$.post('../site/update_product' , $(this).serialize() , function(html){});
});
}) ;
EVETHING WORKS FINE
But if I change this:
Code:
$data['product_id'] = '10';
Code:
$data['product_id'] = $this->uri->segment(3);
And load the page at: I load the page at: http://locallhost/ci/site/products/10
I doesn't work.
I don't know how to solve it BUT I know the problem is JUST this line.