Once the quantity dropdown button is selected, the price field would be changed accordingly. However, I keep on getting successful alert, but the data is showing an empty result.
I have tried using success instead of done but the result is the same. I have also removed datatype: json, still no changes.
$('#qty').change(function(){
var val = $(this).val();
$.ajax({
method: "GET",
url: "someURLHERE",
data: { val: val},
dataType: "html"
})
.done(function(data) {
alert("Success" + data);
$('#price').html(data);
$('#price').trigger('change');
}).fail(function() {
alert("Fail");
})
});
Here is my model:
public function getPrice($product_id, $quantity){
$sql = "SELECT price FROM `price_table` where quantity = '".$quantity."' and product_id = '".$product_id."' ";
$query = $this->db->query($sql)->row_array();
return $query;
}
And here is my controller:
public function getPrice(){
$p_id = $_GET['p_id'];
$qty = $_GET['qty_ag'];
$price = $this->users_model->getPrice($prpduct_id, $quantity);
json_ok($price);
}
Now, the alert box is returning: Success{"status":"OK","data":{"pv_value":"120.00"}}
All I want to get is the value 120.00