Im opening a inappbrowser window for a payment service. After the Payment is done and sucessfull entries in my db will be updated.
user table - rows like
ID - USERNAME - VIPSTATUS - CALLSTATUS
The vipstatus and callstatus gets changed to "1" after payment.When the inappbrowser will be closed i want to get the new data from the vipstatus and callstatus from the user and overwrite the existing localstorage items callstatus and vip status. Username is saved in localstorage as username. Im guessing my ajaxcode is wrong, because it dont work, it dont even load the script.
My Ajax Code
$(document).ready( function() {
$("#paybutton").click(function() {
var params = "projectpaymentoption=1195&id=",
usernamepay = window.localStorage.getItem("username"),
paymenturl = params + usernamepay;
$.ajax({
type: 'POST',
url: 'http://www..de/phone/encode.php',
data: $.param({"paymenturl": paymenturl}),
success: function(result) {
var paybrowser = window.open(result,'_blank','location=no','closebuttoncaption=Zurück');
paybrowser.addEventListener('exit',function(event) {
$.ajax({
type: 'POST',
url: 'http://www..de/update.php',
data: $.param({"username": username}),
success: function(data) {
window.localStorage.setItem("vipstatus", data[2]);
window.localStorage.setItem("callstatus",data[3]);
}
});
}
My UPDATE.PHP Code
<?php
$dbhost = "blabla";
$dbuser = "blabla";
$dbpass = "blabla";
$dbname = "blabla";
$tableName = "user";
print_r($_POST);
$user = $_POST['data']['username'];
print PHP_EOL . $user . PHP_EOL;
$con = mysqli_connect($dbhost,$dbuser,$dbpass);
$dbs = mysqli_select_db($dbname, $con);
$result = mysqli_query("SELECT user$ FROM $tableName");
$array = mysqli_fetch_row($result);
$conn->close();
?>