I have a saveTestObject()
method in a PHP
file, and I need to call it from HTML
with jQuery
. I looked around but there seems to be no complete example out there. I would really appreciate one.
Here's my PHP
file, which is called SM.php
:
<?php
switch($_POST["functionname"]){
case 'saveTestObject':
saveTestObject();
break;
}
function saveTestObject() {
echo "saveTestObject CALLED";
$object = ParseObject::create("TestObject");
$objectId = $object->getObjectId();
$php = $object->get("elephant");
// Set values:
$object->set("elephant", "phpserver");
//$object->set("today", new DateTime());
$object->setArray("mylist", [1, 2, 3]);
$object->setAssociativeArray(
"languageTypes", array("php" => "awesome", "ruby" => "wtf")
);
$object->save();
}
?>
My HTML
form in smpage.html
looks like this:
<form>
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit"/>
</form>
How do I connect the two, so that when I press the submit button the saveTestObject()
function is called?
Both SM.php
and smpage.html
reside in the save directory in my web server's Documents
.