When I press a button with some functionalities(in php code) I don't understand why I receive sometimes error, sometimes succes from ajax. I have one more button which have almost same structure of code to the bottom. So, I have 2 ajax codes with same structure(but different names of variables or files). Is this important ?
Ajax:
function plan_tarifar_submit_anulare() {
var id = get_user_id_anulare();
var myURL = "./UpdateAnularePlanTarifar.php";
$.ajax({
timeout: 5000,
type: "POST",
url: myURL,
data: {id:id},
error: function(xhr) {
alert('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' -> ' + xhr.responseText);
parent.location.reload();
},
success: function (xhr) {
alert('IT WORKS !!' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
parent.location.reload();
}
});
return false;
}
php:
<?php
/**
* Description of updateAnularePlanTarifar (...)
*/
require_once("../includes.inc.php");
$cookie_value = assure_login_check();
if (!isset($_POST['id'])) {
return;
}
$user_id = htmlspecialchars($_POST['id']);
function getOldIstoric($id){
(.....)
return $istoric;
}
function anularePlanTarifar($id) {
(.....)
}
anularePlanTarifar($user_id);
?>
Also, after error the page can't reload: unloaded page
I think that the id is missing at the end of url.