hello
so what i'm trying here is, when i click <a href="" id="admin">e<?php echo $array['username']; ?></a> I want it to pop a modal (custom css, not bootstrap) with including some information about the $array['username'];
I tried AJAX but it didn't send any response. Either success or error.
My code:
It doesn't return anything. Maybe i'm missing something?
Any help appreciated.
Thanks
so what i'm trying here is, when i click <a href="" id="admin">e<?php echo $array['username']; ?></a> I want it to pop a modal (custom css, not bootstrap) with including some information about the $array['username'];
I tried AJAX but it didn't send any response. Either success or error.
My code:
Code:
<script>
$("#admin").click(function() {
function toggleProfile(id) {
$.ajax ({
url: "getProfile.php",
method: "POST",
data:id,
success: function(data) {
$("#profile").html(data);
},
error: function (jqXHR, exception) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status == 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg = 'Internal Server Error [500].';
} else if (exception === 'parsererror') {
msg = 'Requested JSON parse failed.';
} else if (exception === 'timeout') {
msg = 'Time out error.';
} else if (exception === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.\n' + jqXHR.responseText;
}
console.log(msg);
}
});
}
});
</script>
PHP:
<?php
$id = $_POST['id'];
$q = $db->assoc($db->query("SELECT * FROM users WHERE id = '{$id}'"));
?>
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<div style="padding-top:20px;">
<h4>Profile</h4><hr><img src="http://domain.com/pictures/<?php echo $r['username']; ?>.png" style="border-radius: 5000px; float:right; width:300px; height:300px;"/></div>
<h2><?php echo $q['username']; ?> </h2> <div style="padding:10px;"><?php if($q['is_away'] == 1) { ?><div style="border:5px solid rgb(115,56,128);border-radius:3px; height:25px;width:125px; background: rgb(0,0,0); font-weight:bold;color:white;padding:10px;"><center>This user is away</center></div></div><?php } ?>
<p><B>Region</b>: <?php echo $q['region']; ?></p>
<p><b>Rank</b>: <?php echo $q['rank']; ?></p>
<?php
if($user->hasGroup('4') || $user->hasGroup('5')){
?>
Admin actions<br>
<form method="post" action="" >
<input type="submit" class="mws-button red" value="Log out this user." name="logout">
</form><br>
<form method="post" action="" >
<input type="submit" class="mws-button red" value="Alert this user." name="alert">
</form><br>
<form method="post" action="" >
<input type="submit" class="mws-button red" value="Suspend this user." name="suspend">
</form>
<?php
if($_POST['logout']) {
$user->logoutUser($uid['id']);
}
}
?>
</div>
</div>
</div>
</div>
It doesn't return anything. Maybe i'm missing something?
Any help appreciated.
Thanks
Last edited: