[eluser]Javatuan[/eluser]
Here is my view
Code:
<select name="producttypecode" id="producttypecode">
<option value="GA02">GA027</option>
<option value="GA04">GA047</option>
</select>
<div id='product' name='product'>test</div>
< script language="JavaScript">
$(document).ready(function() {
$('#producttypecode').change(function() {
var producttypecode = $(this).val();
$.post('index.php/product/productlist',
{'producttypecode': producttypecode},
function (data){
alert (data);
//$('#product').replaceWith(data.result);
}, 'json');
});
});
</ script>
Here is my "product" controller
Code:
// for ajax request
function productlist(){
$producttypecode = trim($this->input->post('producttypecode'));
$productSearch = array('TYPE_CODE' => $producttypecode);
$productlist = $this->Product_model->getProduct($productSearch);
echo 'processed';
//echo json_encode($productlist);
}
In Firebug/NET, there's already the response of 'processed'. However, I cannot alert or use 'replaceWith' with the data returned. Is there any mistake here?
Thank you in advance!