Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

damith88 on "Front end Plugin with ajax post doesn't work when admin logged in to site"

$
0
0

These days I am developing my own plugin to redirect my wordpress home page into different pages according to users selection via some drop down menus.

Everything on front end and back end working fine. But I have a problem that is when admin logged in to wordpress site, same browser front end doesn't work any more.

This plugin front end use jquery and ajax post. can any one please tell me why front end stop work when admin logged into the wordpress back end.

Below are the working code.

js file
----------

jQuery(document).ready( function($) {

  $("#year_select").live('change', function() {

        $("#load_id").show();
          $.post('wp-admin/admin-ajax.php', {
            action: "ci_getyear",
            year_id: $('#year_select').find(":selected").text()
            }, function(data) {
            $("#make_select").html($(data));
            $("#load_id").hide();
            }
            );
            return false;
        });
});

php file
----------------------

function ci_getyear_return()
{
	$year_id = $_POST['year_id'];

            global $wpdb;

            $ci_make = $wpdb->get_results("SELECT DISTINCT ci_make FROM ".$wpdb->prefix."carinfo WHERE ci_year=$year_id", ARRAY_A );

               echo "<option value=\"\">--Select--</option>";
               for ($i=0; $i<  count($ci_make); $i++)
                {
                    $ci_opt_value = $ci_make[$i][ci_make];
                     echo "<option value=\"$ci_opt_value\">$ci_opt_value</option>";

                }
          die(); 

}

add_action('wp_ajax_nopriv_ci_getyear','ci_getyear_return');

function get_ci_year_method() {
	wp_enqueue_script(
		'newscript',
		plugins_url( 'car_info.js' , __FILE__ ),
		array( 'jquery' )
	);
}

add_action( 'wp_enqueue_scripts', 'get_ci_year_method' );

------------------------------------------

You can see my working plugin in below URL

http://websolutionslk.com/wpress/

and also you can use following user name and password to check the issue
username: [removed]
password: [removed]

Please help me to solve this issue.

Thank you
Damith


Viewing all articles
Browse latest Browse all 26892

Trending Articles