Example of asynchronous deletion using js in Yii2.0 and yii2.0js

Source: Internet
Author: User

Example of asynchronous deletion using js in Yii2.0 and yii2.0js

Sort out the document, search for an example of using js asynchronous deletion in Yii2.0, and streamline it for sharing.

Controller:

public function actionWeixinnotificationdel(){ $model = WxDistributorNotification::findOne($_GET['id']); if ($model) {  if($model->delete()) {   echo 1;   Yii::$app->end();  } } echo 0; Yii::$app->end();}

View HTML

Copy codeThe Code is as follows:
<A href = "javascript: void (0);" rel = "external nofollow" url = "<? = Url: to (['weixinnotifdel ', 'id' => $ model-> id]);?> "Class =" btn-success btn-sm deleteLink "> unbind </a>

View JS

<Script language = "Javascript"> $ (function () {$ ('. deleteLink '). click (function () {var tThis = $ (this); if (confirm ("are you sure you want to unbind this number? ") {Var url = tThis. attr ('url'); $. get (url, function (data) {if (data = 1) {$ (tThis ). parent (). parent (). remove () alert ('unbinding successfully')} else {alert ('unbinding failed') }}return false ;}) </script>

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.