TP5 framework based on Ajax to achieve asynchronous deletion of pictures method example


This paper describes the method of asynchronous deletion of pictures based on Ajax in TP5 framework. The details are as follows:

In order to improve the user experience, we have made Ajax non refresh asynchronous deletion function for the commodity album. The process and method are very worthy of reference. The effect is as follows:

In the picture list above, you can click the minus sign next to it to delete the picture not only from the web page, but also from the server without refreshing the current page. Let’s take a look at our core processing code

The first is the JS code of the client

function delrow(o){
If (confirm ('are you sure you want to delete this graph?){
var div=$(o).parent().parent();
var id=div.attr('id');
Alert ('delete failed ');

When the request is sent to the server, we handle it as follows:

//Asynchronous deletion of product album pictures public function ajaxdelpic ($ID){
echo 1;
echo 2;

For more information about ThinkPHP, interested readers can check out the following topics: introduction to ThinkPHP, summary of operation skills of ThinkPHP template, summary of common methods of ThinkPHP, introduction to CodeIgniter, CI (CodeIgniter) framework advanced course, Zend framework introduction course and PHP template technology summary.

I hope this article will be helpful to the design of PHP program based on ThinkPHP framework.