《PHP編程:Yii2.0中使用js異步刪除示例》要點(diǎn):
本文介紹了PHP編程:Yii2.0中使用js異步刪除示例,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
相關(guān)主題:YII框架
PHP編程整理文檔,搜刮出一個(gè)Yii2.0中使用js異步刪除示例,稍微整理精簡一下做下分享.
PHP編程控制器:
PHP編程
public function actionWeixinnotificationdel()
{
$model = WxDistributorNotification::findOne($_GET['id']);
if ($model) {
if($model->delete()) {
echo 1;
Yii::$app->end();
}
}
echo 0;
Yii::$app->end();
}
PHP編程視圖HTML
PHP編程視圖JS
PHP編程
<script language="JavaScript">
$(function () {
$('.deleteLink').click(function () {
var tThis =$(this);
if (confirm("確定要解綁此微信號(hào)嗎?")){
var url = tThis.attr('url');
$.get(url,function (data) {
if (data == 1){
$(tThis).parent().parent().remove()
alert('解綁成功')
}else{
alert('解綁失敗')
}
})
}
return false;
})
})
</script>
PHP編程以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持維易PHP.
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/1500.html