I have a custom interface that uses 30+ ajax files while running...
some files are only used in category.php while othere's are only
used in page.php...
i include the ajax loader php files in my functions.php file
example:
include TEMPLATEPATH . '/ajaxLoops/ajax-open_client_editform.php';
include TEMPLATEPATH . '/ajaxLoops/ajax-submit_client_editform.php';
It all works great but when i tried to conditionally load them
using is_page or is_category directly in my functions.php the ajax
functions stop working.
example:
if(is_page()) {
include TEMPLATEPATH . '/ajaxLoops/ajax-open_client_editform.php';
}
include TEMPLATEPATH . '/ajaxLoops/ajax-submit_client_editform.php';
i guess this is a matter of loading order or some other issues i am
unaware of.... Could you help me understand the problem with my approach
or an alternative way of conditionally loading this files?...
Cheers,
Sagive.
EDIT 1 (.PHP AJAX LOADER FILE):
<?php
wp_enqueue_script( 'ajax-simple-example', get_stylesheet_directory_uri().'/ajaxLoops/ajax-simple_example.js', array('jquery'), 1.0 ); // jQuery will be included automatically
wp_localize_script( 'ajax-simple-example', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); // setting ajaxurl
add_action( 'wp_ajax_action_simple_example', 'ajax_simple_example' ); // ajax for logged in users
function ajax_simple_example() {
// just an empty example for my question
// in stackexchange
echo '<div id="success">'.$successMsg.'</div>';
die(); // stop executing script
}
?>