I'm trying to retrive some code from a php method using ajax, when a person click a div.
HTML
<div class="contenitore">
<div>
<input class="idCommento" value="//some number">
</div>
<div>
<p class="vediRisp">Create text</p>
</div>
</div>
<div class="contenitore">
<div>
<input class="idCommento" value="//some number">
</div>
<div>
<p class="vediRisp">Create text</p>
</div>
</div>
PHP (lib/Users.class.php)
Class Users{
public function dammi_i_commenti(arguments){
return '<div>code</div>';
}
}
(lib/ottieniCose.php)
require('Users.class.php');
$login = New Users;
$GLOBAL['current'] == $_GET['adesso'];
print $login->dammi_i_commenti();
AJAX
$(".vediRisp").on('click', function() {
var mh = $(this).parentsUntil(".contenitore").find(".idCommento");
var eeeh = mh.val();
$.ajax({
url: "lib/ottieniCose.php",
type: "GET",
data: {
adesso: eeeh,
},
})
.done(function() {
console.log("success");
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
});
When i click the .vediRisp
in the console i can read success
, then complete
, so I'm thinking that the click and ajax function work, but the page doesn't seem to update its content therefore i think that i'm not calling the method correctly. Anyway if i try to write var_dump("stuff")
or print_r("stuff")
in the ottieniCose.php file i get absolultely no result at all, and my guess is that i'm not using the ajax function correctly, or the ottieniCose.php file isn't called.
Any help?