I made a page, using the Smarty template. The data is read in index.php and then displayed in the Index.tpl file. However, the TPL file has a button to sort the data as specified. For example, my default is that index.php is read from the database in the order of 1,2,3,4. Then there is a button in the TPL file, and the 4,3,2,1 is displayed on the following page. For now, I want to know how to transfer that click event to index.php and then index.php read the data as specified and then display it in the TPL file.
I wrote a click event in the TPL file, want to use Ajax to pass, capture the packet display, index.php also read out the data, but the current TPL file shows the previous.
$ ("#sortbypop"). Click (function () {
var url = document. URL;
$.get (url,{action: "Get", Sort: "Popsort"},function (data,textstatus) {
});
});
This is the AJAX code. What should I do?
Reply to discussion (solution)
Your callback function (data,textstatus) {} function body is empty, and of course nothing is done
The specific thing to do depends on the scene you're designing.
The original is Xu senior! Find a master.
So, because I don't need to do anything, what I want to do is to submit a parameter in the INDEX.TPL to get the background PHP program to read the database data again and then show it again. The process is equivalent to tpl--> submit parameter--->php get reread data--->TPL update display is this feature. The point is that my data is read in index.php and then display (INDEX.TPL). What I want to do now is that the TPL will pass the arguments back, PHP reread, and then retransmit the data to the TPL. I've been dizzy ....
Your callback function (data,textstatus) {} function body is empty, and of course nothing is done
The specific thing to do depends on the scene you're designing.
is to click on the new product sort and click on the sorting, will show different data
In function (Data,textstatus) {}
The data is clearly the return, how to display this data, and your design. How do people know?
In function (Data,textstatus) {}
The data is clearly the return, how to display this data, and your design. How do people know?
This callback function can be used, and I'm testing it. I mean my idea of how to achieve, in fact, is a very simple question, I estimate to go around. White Point is
PHP reads a row of data and then displays it in the template. Now the template has a button function that requires PHP to reorder the data and then display it to the template. The specific process is the front page tpl-->php-->tpl this. Now I'm doing the test. Alert the data in the next function, displaying the new HTML complete code. That is, the data returned by the callback function, even the display (TPL) file in the PHP file, is returned. So the whole HTML code is returned. However, the current TPL page does not change. The function I want to do is to click and then change the order of the pictures displayed in the middle. Do not click, is the default order.
The callback function is not available, and the data should only be the content of the area that needs to be changed.
So you're using data to replace the target area's content?
That is the JS operation, with data to replace the following content is OK.
The callback function is not available, and the data should only be the content of the area that needs to be changed.
So you're using data to replace the target area's content?
The main data request now is index.php. So all the data in the index.php is returned, including display (TPL). Now data is an entire HTML page content. The data inside is not good to take out. Want to see if there's a more convenient way
If you want to use Ajax to do a partial refresh, then you have to take the template apart. That is, different requirements with different templates
If you want to refresh the whole, don't use Ajax
If you want to use Ajax to do a partial refresh, then you have to take the template apart. That is, different requirements with different templates
If you want to refresh the whole, don't use Ajax
The original is just separate on it. I have been pursuing the overall refresh using Ajax, going the wrong way, too paranoid about me. Doches Teacher!