0
I need to pass the id value of each link to a modal.
You are returning this error in the console: What I need to resolve?
custom.js:5 Uncaught TypeError: $.ajax is not a function
at HTMLAnchorElement.<anonymous> (custom.js:5)
at HTMLAnchorElement.dispatch (jquery-3.2.1.slim.min.js:3)
at HTMLAnchorElement.q.handle (jquery-3.2.1.slim.min.js:3)
(anonymous) @ custom.js:5
dispatch @ jquery-3.2.1.slim.min.js:3
q.handle @ jquery-3.2.1.slim.min.js:3
I’m using the AJAX.
Link
<a href="#" id="<?php echo $row['id_usuario']; ?>" class="push" data-toggle="modal" data-target="#abrir">click</a>
AJAX
$("a[data-toggle=modal]").click(function()
{
var essay_id = $(this).attr('id');
$.ajax({
cache: false,
type: 'POST',
url: 'ajax_paciente_id.php',
data: 'EID='+essay_id,
success: function(data)
{
$('#abrir').show();
$('#modalContent').show().html(data);
}
});
});
Modal
<div class="modal fade" id="abrir" tabindex="-1" role="dialog" aria-labelledby="abrir" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body modalContent">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
PHP
<?
echo $_POST['essay_id'];
?>
i switched to the full version, and did not return the error, but is not passing the id value yet.
– Wagner
@Wagner changes your line
data: 'EID='+essay_id,
fordata:{EID:essay_id},
– Lucas
I did that and it hasn’t passed the id value yet. It looks like it’s not even calling the php file ajax_paciente_id.php
– Wagner
puts a
console.log()
inside the Success and look at the console to see if it is calling or not, or if it is returning error– Lucas
Did not return anything, the problem must be the one that is not calling the file.
– Wagner
may also be that it is calling but is returning error, does the following: takes the
essay_id
and puts a fixed value, and gives a look if it returns– Lucas
strange, does not return anything tbm did so date:{EID:'ssss'}, is the problem not here? $("a[data-toggle=modal]"). click(Function()
– Wagner
Let’s go continue this discussion in chat.
– Lucas