php - Ajax data function that should work but doesn't -


within application have ajax function adds information database. worked until added in 2 more parameters location , username. still works else doesn't add last 2 database. names of within database location , username. assignedusername , storelocation set else in code.

ajax:

$("#send").click(function(){     $.ajax({         type: 'post',         contenttype: "application/json",         data: orderfood(),         url: rooturl + "/orderfood",         datatype: "json",         success: function(data)         {             alert(assignedusername);             alert("data added");              $.mobile.changepage("#mainmenu");         },         error: function(data)         {             alert(assignedusername);             alert("data not added");              $.mobile.changepage("#mainmenu");         }     }); });  function orderfood() {        alert(storelocation + ", " + assignedusername);     return json.stringify({             "food1": food1,             "food2": food2,             "food3": food3,             "food4": food4,             "food5": food5,             "food6": food6,             "food7": food7,             "food8": food8,             "food9": food9,             "location": storelocation,             "username": assignedusername     }); } 

php:

$app->post('/orderfood/', 'orderfood');  function orderfood() {     $request = \slim\slim::getinstance()->request();     $q = json_decode($request->getbody());     $sql = "insert subsordered(food1, food2, food3, food4, food5, food6, food7, food8, food9, location, username) values (:food1, :food2, :food3, :food4, :food5, :food6, :food7, :food8, :food9, :location, :username)";     try     {         $db = getconnection();         $stmt=$db->prepare($sql);         $stmt->bindparam("food1",$q->food1);         $stmt->bindparam("food2",$q->food2);         $stmt->bindparam("food3",$q->food3);         $stmt->bindparam("food4",$q->food4);         $stmt->bindparam("food5",$q->food5);         $stmt->bindparam("food6",$q->food6);         $stmt->bindparam("food7",$q->food7);         $stmt->bindparam("food8",$q->food8);         $stmt->bindparam("food9",$q->food9);         $stmt->bindparam("location",$q->location);         $stmt->bindparam("username",$q->username);         $stmt->execute();         $db = null;     }     catch(pdoexception $e){         echo $e->getmessage();     } } 

i know php correct though testing curl thought i'd include whole picture

i extremely stuck this, can see should work doesn't


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -