I have a CS:GO gamble site where user have to save his Steam Trade URL, i have made an JQuery AJAX post to save the data on database:
$(document).on('click', '#saveURL', function(e) {
var data = $("#tradeURL").serialize();
$.ajax({
data: data,
type: "post",
url: "functions/tradeURL.php",
success: function(data) {
noty({
text: '<b>Success!</b> <br>Your Trade URL is now saved.',
layout: 'topRight',
theme: 'metroui',
type: 'success',
maxVisible: 10,
timeout: 5000,
closeWith: ['click', 'timeout'],
animation: {
open: {
height: 'toggle'
},
close: {
height: 'toggle'
},
easing: 'swing',
speed: 500 // opening & closing animation speed
}
});
}
});
});
If the data was submitted correctly it gives that alert, but my tradeURL.php contains this code:
if (isset($_REQUEST)) {
$tradeURL = $_POST["tradeURL"];
$tradeURL = htmlspecialchars(str_replace('', '', $tradeURL));
$turl = explode("=", explode("&", "'.$tradeURL.'") [0]); // user trade url
if ($turl[1] == $steamid - intval(0x0110000100000000)) {
$update = "UPDATE users SET tlink='$tradeURL' WHERE steamid=$steamid";
if ($db->query($update) === TRUE) {
// THIS GIVES THE ALERT ON THE JQUERY SCRIPT
}
else {
echo "Error updating record: " . $db->error;
}
}
else {
// HOW TO OUTPUT THIS ON THE AJAX POST ?
}
}
So how i should make an alert to that part where it says // HOW TO OUTPUT THIS ON THE AJAX POST ? and it would save it to database.