0
I have a code that plays an ID in HTML for a link:
<a href="javascript:confirmacao(<?php echo $row['idfoto'] ?>)"> <i class="fas fa-trash"></i></a>
Already in Javascript I have the code that calls the file delete.php
, that takes the ID.
function confirmacao(id) {
var resposta = confirm("Tem certeza que deseja remover essa informação?");
if (resposta == true) {
$.ajax({
url: '/delete.php?delete_id=' + id,
type: 'GET',
dataType: 'json'
}).done(function (data) {
$.get("/read.php", {}, function (data, status) {
$('.read_content').html(data);
});
});
}
}
I made a modification and created a function inside the ready
jQuery as above, which is giving this error when I click on the link.
VM499:1 Uncaught Referenceerror: confirmation is not defined at :1:1 (Anonymous) @VM499:1
Are you saying that the function is not set, will have something to see with jQuery?
The function needs to be declared in the global scope to be called the way you did. And in your code must be in the scope of a jq load/ready Handler.
– bfavaretto
She’s inside
$(document).ready(function () { }
– JB_
So, exactly what I thought, you need to take it from there and leave it in the global scope.
– bfavaretto
There is some way to change this function and to keep it within the scope of the ready so of Jquery?
– JB_
If she’s in the global scope she’ll also be in the ready scope. just move her out.
– bfavaretto
There’s only one problem, I don’t know if on account of it’s out of scope, the $.get is not working to display the data in the div and updating the information.
– JB_