Support » Plugins » plugin functions and Ajax help

  • i am trying to write a plugin that processes ajax post requests makes a database request and returns json as the result. right now i am just trying to get the request and response right. the problem that i am running into is that the parse_request function (rmm_add_signature()) is being run on every page load on my site. and when i make an ajax call it returns the entire page.

    my question is, how do i only run that function when it is called via the url, and secondly how do i keep the rest of the theme from loading as well?

    function rmm_add_signature()
    	$fields['pet_id'] = $_POST['pet_id'];
    	$fields['F_Name'] = $_POST['F_Name'];
    	$fields['L_Name'] = $_POST['L_Name'];
    	$fields['Zip_Code'] = $_POST['Zip_Code'];
    	$fields['Email'] = $_POST['Email'];
    	$fields['Comment'] = $_POST['Comment'];
    	$fields['Opt_In'] = $_POST['Opt_In'];
    	echo json_encode($fields);
    function rmm_query_vars($vars)
    	$vars[] = 'my-plugin';
    	return $vars;

    this is my first crack at writing a wordpress plugin. however i have been working with php for the last year or so.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘plugin functions and Ajax help’ is closed to new replies.