Yii에서 프로젝트를 구현했습니다. 아약스 함수를 사용하여 테이블에서 데이터를 삭제하고 싶습니다. 그것은 작동하지 않습니다ajax를 사용하여 세 개의 다른 테이블에서 데이터 삭제
<td id="data">
<?php
echo $i++;
?>
</td>
<td id="data">
<?php
$type=Ingredienttype::model()->find("id=$type_id");
echo $type['ingredient_type'];
?>
</td>
<td id="data">
<?php
$type1=Ingredient::model()->find("ingredient_id=$ingredient_id");
//echo $ingredient_id;
echo $type1['ingredientname'];
?>
</td>
<td id="data">
<?php
echo $quantity;
?>
</td>
<td id="data">
<?php
$mes_type=Measuringtype::model()->find("id=$measuringtype");
echo $mes_type['measuringname'];
?>
</td>
<input type="button" id="<?php echo $type_id; ?>" name="doesntMatter" class="REMOVETHIS btn btn-inverse btn-xs"
value="Del" onclick="removeRow1(this.id,<?php echo $model->recipe_id ?>)"/></td>
: 나는 하나의 행으로이 세 테이블의 데이터를 표시
<script>
function removeRow1(x,y){
alert("Are sure want to delete");
$.ajax({
url: '<?php echo Yii::app()->createAbsoluteUrl("ingredients/delete1"); ?>',
type: 'POST',
data: 'x1='+x+'&r_id='+y,
success: function(res)
{
//alert(res);
////$("#truth").html(res);
},
error:function(){
alert("Failed request data from ajax page");
}
});
}
</script>
: 내보기 부분에서
public function actionDelete1(){
if (isset($_POST['x1']) && isset($_POST['r_id'])) {
$hid=$_POST['x1'];
$rid=$_POST['r_id'];
echo $_POST['x1'].'recipe_id'.$_POST['r_id'];
$query="delete from ingredients where ingredienttype_id='$hid'";
$query1=Yii::app()->db->CreateCommand($query)->execute();
$this->redirect(array('recipe/update','id'=>$rid));
}
}
: 내 컨트롤러에서
내가 쓴 . 아약스를 사용하여 ID를 삭제하는 방법을 제안 해주세요.
그리고 ... 당신의 질문은 ...? –
그것의 작동하지 않는 친구 –
글쎄, "젠체하는"분명히 모든 것이 잘 작동했다면 여기에 없을 것이다. 문제에 대해 더 자세히 이야기 해 주시겠습니까? 조용히 실패하고 있습니까? 시공간 연속성을 깨고 있습니까? 오류 메시지가 있습니까? 오류가 클라이언트 측 또는 서버 측입니까? 어느 시점에서 오류가 발생합니까? (데이터를 보낼 때 서버에서 처리 할 때 응답을 처리 할 때 ...?)? 알다시피, 우리가 추측 할 수없는이 모든 것들이 ... –