hi! I've added ajax to wordpress on the viewer-facing side it is a form filled by ajax when is entered email and password it worked, now it doesn't work anymore even if I use the originally code from wp codex:
andCode:function myplugin_js_header() // this is a PHP function { // use JavaScript SACK library for Ajax wp_print_scripts( array( 'sack' )); // Define custom JavaScript function ?> <script type="text/javascript"> //<![CDATA[ function myplugin_cast_vote( vote_field,vote2_field, results_div ) { alert("hello"); var mysack = new sack( "<?php bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php" ); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar( "action", "my_special_action" ); mysack.setVar( "vote", vote_field.value ); mysack.setVar( "results_div_id", results_div ); mysack.onError = function() { alert('Ajax error in voting' )}; mysack.runAJAX(); return true; } // end of JavaScript function myplugin_cast_vote //]]> </script> <?php } // end of PHP function myplugin_js_header function my_action_callback() { // Check request came from valid source here // TO DO! // read submitted information $vote = $_POST['vote']; $results_id = $_POST['results_div_id']; // Put your vote processing code here // In this example, assume // a) The processing code sets global // variable $error to a message if there is an error // b) If there is no error, $results contains // the HTML to put into the results DIV on the screen // Here you can even access the database by using the // global $wpdb $error = ""; $results = "HTML to put into the results DIV on the screen"; if( $error ) { die( "alert('$error')" ); } // Compose JavaScript for return die( "document.getElementById('$results_id').innerHTML = '$results'" ); }
it worked beforer after that i write the ajax code for admin side, i include it in the main php file of the plugin do you thinkCode:add_action('wp_ajax_my_special_action', array(&$this, 'my_action_callback')); add_action('wp_ajax_nopriv_my_special_action', array(&$this, 'my_action_callback'));
they are in conflict?? if i put an alert the alert work but ajax doesn't work anymore
it' called here: onchange="javascript:myplugin_cast_vote(this.form. email,this.form.pass,'emailmsg');"
could you help me?? thank you


LinkBack URL
About LinkBacks
Reply With Quote