I have javascript as below:
$.ajax({
type: "POST",
url: "ajax.php",
data: {
filename: $("#title1").html()
},
success: function(response){
$cell1.css("background-image", "url('pdfthumb/" + response + ".jpg')");
}
});
$.ajax({
type: "POST",
url: "ajax.php",
data: {
filename: $("#title2").html()
},
success: function(response){
$cell2.css("background-image", "url('pdfthumb/" + response + ".jpg')");
}
});
$.ajax({
type: "POST",
url: "ajax.php",
data: {
filename: $("#title3").html()
},
success: function(response){
$cell3.css("background-image", "url('pdfthumb/" + response + ".jpg')");
}
});
$.ajax({
type: "POST",
url: "ajax.php",
data: {
filename: $("#title4").html()
},
success: function(response){
$cell4.css("background-image", "url('pdfthumb/" + response + ".jpg')");
}
});
and much more ... Every time I want a result, I have to use ajax, and this made the script long. Is there a way to shorten the code?
You can see my full code here . I will be very grateful if someone corrects my code.
Thanks for the help..
blasteralfred
source
share