Home > Backend Development > PHP Tutorial > thinkphp3.2 uses ajax to delete columns and shares examples

thinkphp3.2 uses ajax to delete columns and shares examples

小云云
Release: 2023-03-21 11:34:02
Original
1609 people have browsed it

This article mainly shares with you examples of using ajax to delete columns in thinkphp3.2. I hope it can help you.

1. Problems encountered

(1) The data data of $.post cannot be placed in the URL for transmission, otherwise it will be equivalent to the get method

(2) The data obtained by ajax cannot be returned directly. You need version 3.2 to use ajaxReturn

$this->ajaxReturn ($data);
Copy after login

(3) There is no way to add return parameters in the custom function of html because $vo.id## cannot be used. #

$vo['id']
Copy after login

Second solution

(1)javacript:; is not operated by default

(2)setTimeout indicates the code code delay time

删除
Copy after login
 $('.del').click(function(){
        var did=$(this).attr("data-id");
        var url="{:U('Daily/dailyQuestionDel')}";

        $.post(url,{id:did},function(data){
            if(data.status == 1){
                layer.msg(data.msgs);
                var t=setTimeout("location.href = location.href",500);

            }else{
                layer.msg(data.msgs);
                var t=setTimeout("location.href = location.href",500);
            }
        });
    });
Copy after login
Related recommendations :

ThinkPH implements code sharing for batch deletion of columns

Use Tp to delete columns

How to delete columns in ThinkPHP?

The above is the detailed content of thinkphp3.2 uses ajax to delete columns and shares examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template