Welcome Guest, Not a member yet? Register   Sign In
Can't get URI class and jquery Ajax resquest working right.
#1

[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

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>

&lt;/form&gt;
and the js which fire the request:
Code:
$(document).ready(function() {

    $('.updateProduct').live('submit',function(eve) {
        eve.preventDefault();

        $.post('../site/update_product' , $(this).serialize() , function(html){});
        
    });
}) ;
I load the page at: http://locallhost/ci/site/products/
EVETHING WORKS FINE

But if I change this:

Code:
$data['product_id'] = '10';
for this:(so that I can pass the id in the url)
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.


Messages In This Thread
Can't get URI class and jquery Ajax resquest working right. - by El Forum - 02-01-2010, 11:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB