Код: Выделить всё
function save(obj){
var res = obj.id.split("-");
$.ajax({
var url="";
type: "POST",
data: {status: this.value},
success: function(data) {
if(obj.id=='btnyes-'+res[1]){
var yesid='btnyes'+res[1];
document.getElementById('btnyes-'+res[1]).style.display = 'none';
document.getElementById('btnno-'+res[1]).style.display = 'none';
document.getElementById('yes-'+res[1]).style.display = 'block';
document.getElementById('no-'+res[1]).style.display = 'none';
}
else if(obj.id=='btnno-'+res[1]) {
document.getElementById('btnyes-'+res[1]).style.display = 'none';
document.getElementById('btnno-'+res[1]).style.display = 'none';
document.getElementById('yes-'+res[1]).style.display = 'none';
document.getElementById('no-'+res[1]).style.display = 'block';
}
alert("Ajax save executed!");
}
}
});
}
этот скрипт должен вызывать функцию ajax и обновлять значение как 1 или 0
в зависимости от onclick.
Но она не обновляется..в чем ошибка?
Код Ajax приведен ниже
Код: Выделить всё
public function approveinfo($approve="") {
if(!empty($approve)) && ($approve=='yes') {
$this->Purchaseorder->updateAll(array('Purchaseorder.approve' =>"1"),
else{
$this->Purchaseorder->updateAll(array('Purchaseorder.approve' =>"0"),
}
$result=array();
array_push($result,$info);
echo json_encode($result);
exit;
}
}
Подробнее здесь: https://stackoverflow.com/questions/343 ... se-cakephp
Мобильная версия