Load jquery change get url
So, I have a php page with dynamically displayed data depending on the $ _GET ['file'] variable. I have another page (index.php) that has a jQuery script that uses the load () function to load a php page. I have a list of links and when you click on it it needs to change the $ _GET variable to load and then update the jQuery load () variable. Here's a snippet:
$("#remote-files").load("data.php?file=wat.txt");
$(".link1").mousedown(function() {
$("#remote-files").load("data.php?file=link1.txt");
});
As you can see it is loading data into a div with the id of the deleted files. Is there a better way to do this, like refreshing the page with a new get variable instead of overriding the new load function?
+2
a source to share
1 answer
Not really sure what you are asking, or what I suggest is much better, but ...
function loadData(filename) {
$("#remote-files").load("data.php?file=" + filename);
}
loadData("wat.txt");
$(".link1").click(function() {
loadData("link1.txt");
});
This will reduce some of the duplication anyway.
+2
a source to share