require_once '../database_access.php'; $ei = new EventInterest(); if (isset($_POST['interested_user_id'])) { $ei->setInterestedUserId($_POST['interested_user_id']); } if (isset($_POST['target_event_id'])) { $ei->setTargetEventId($_POST['target_event_id']); } if (isset($_POST['bringing_car'])) { $ei->setBringingCar($_POST['bringing_car']); } if (!$ei->validate()) { foreach ($ei->getValidationFailures() as $failure) { echo '<p><strong>Error in ' . $failure->getPropertyPath() . ' field!</strong> ' . $failure->getMessage() . '</p>'; } unset($failure); } else { //Check to see if this interest is already here. $eq = EventInterestQuery::create()->filterByInterestedUserId($_POST['interested_user_id'])->filterByTargetEventId($_POST['target_event_id'])->count(); if ($eq != 0) { echo '{ "extant": 1 }'; } else { $ei->save(); // add the author name and return the JSON $ei_json = json_decode($ei->toJSON()); $author = $ei->getInterested(); $ei_json->authorFirstName = $author->getFirstName(); $ei_json->authorLastName = $author->getLastName(); echo json_encode($ei_json); } }
// if the request fails error: function( xhr, status, errorThrown ) { alert( "Sorry, there was a problem adding your interest! Please try again in a few moments." ); console.log( "Error: " + errorThrown ); console.log( "Status: " + status ); console.dir( xhr ); }, }); }); //remove interest form $(".remove_interest").submit(function(event) { //get interest id <?php $interest = EventInterestQuery::create()->filterByInterestedUserId($_SESSION['uid'])->filterByTargetEventId($event_id)->find(); $i_id = $interest->getEventInterestId(); ?> i_id = <?php echo $i_id; ?> $.post("../interest/remove_interest.php", { event_interest_id : i_id }, function(data) { $("td[interestid='"+i_id+"']").remove(); }, "text"); } }); </script> </div>