I wrote a wordpress plugin that adds some comment features to my template. Through ajax, all data should be transferred to the wordpress database.
The problem is that the ajax handler needs a php file to capture the request through
if(isset($_POST['name'], $_POST['title'], $_POST['description'])) { // do something with wordpress actions, eg get_current_user, $wpdb }
While the user is submitting the request, the ajax handler calls the php file as follows:
$('#ajax_form').bind('submit', function() { var form = $('#ajax_form'); var data = form.serialize(); $.post('../wp-content/plugins/test/getvars.php', data, function(response) { alert(response); }); return false;
getvars.php does not know the wordpress environment, because it is called directly from the submit user, and I think that adding classes to the Wordpress environment does not include a good style.
Is there another way? Thanks for the support.
source share