0
I have this code below in ajax:
<script>
$("a").live("click", function(event) {
var targeturl = $(this).attr("href");
$.ajax({
type: "get",
url: "/"+targeturl +"",
data: "",
dataType: "html",
success: function(html){
jQuery('#add2').hide().html(html).fadeIn(1000);
location.reload();
}
}); // closing for ajax
event.preventDefault();
});
</script>
And this code in PHP:
while($row = $stm->fetch()) {
$color = completePayment($row["pago"]);
"<div id=add9 align=middle style='color: {$color}; text-shadow: 1px 1px 1px black, 0 0 20px blue, 0 0 1px darkblue'>" .$row['pago'] . " <div id=add2 align=middle <br><br> <a id=add2 href=pago.php?id=". $row['id'] ."><img src=images/pago.png><a href=naopago.php?id=". $row['id'] . " ><img src=images/naopago4.png >
I just put in the interesting section of the code. The page has two images (Paid and Not Paid), when I click paid, it takes the user ID and gives an Update in the bank , setting the value YES, and automatically this same value on the page, when it is not paid, does the same process. Bring the information NOT by setting this value in the Bank. The problem that Ajax is not working, when I take Ajax the page runs and when I leave this code, it does not run, I click on the images and nothing happens.
What version of jQuery?
– Diego Marques
I have two jquery-1.8.2.js and 1.9.0 arrows
– user54154
I left only 1.9.0 and now it runs, but giving Ubmit to the file that makes the change in the bank, and the right was to stay on the page without giving Ubmit to another right.
– user54154
Can’t have 2 jQuery. Use only one. About what I said above you want the page not to refresh ne?
– Willian Coqueiro
Exactly, with two nothing happened, now with the latest version, it directs to the page that makes the update in the bank and the right was to do the update of the bank without leaving the page.
– user54154
Take that out of the script:
location.reload();
. There you are asking to reload the page.– Willian Coqueiro