When I click delete button confirmDelete function call and it post the parameters as json below. it comes back from server page and enter the success method but without any value.. not null just blank string:"" I cant figure out whats the problem I post and get datas inside the form in same page that works fine but this isn't.. what I am missing ?
confirmDelete = function()
{
var data = {
"action": "DeleteLocalObject",
"objectName":intenttoDeleteobjectTitle
};
$.ajax({
url:"../../Controller/ObjectController.php5",
type:"POST",
//contentType: "application/json",
data: data,
success: function(data) {
debugger
if(data.Passed)
{
setTimeout(function () {
location.reload(true);
}, 1500);
}
else
{
}
},
error:function(a, b, c){
}
});
}
and here response page:(I don't implement delete yet just want to check request is ok)
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{
if (isset($_POST["action"]) && !empty($_POST["action"])) { //Checks if action value exists
$action = $_POST["action"];
switch($action)
{ //Switch case for value of action
case "CreateLocalObject":
$controllerObject->createNewLocalObject($_POST["objectname_new"],$_POST["objectcomment_new"],$_POST["type_new"],$_POST["ipaddress_new"]);
break;
case "DeleteLocalsObject":
$result =$_POST["objectName"];//this must get value
echo json_encode($result);//and this must print data to success method
break;
}
I assumed it will return the same object name I posted.