ajax + wordpress

in header.php

$(document).ready(function() {

    $(“#paymentmethod select”).change(function(){            
      var data = {
    action: ‘showPayPalAfterRev’,
    payactiveh: $(“#paymentmethod select option:selected”).val()
     jQuery.post( ‘<?php bloginfo(‘siteurl’); ?>/wp-admin/admin-ajax.php’, data, function(response) {

        if($(this).val() == ‘نقدا بالفندق’){ // or this.value == ‘volvo’
  } else if ($(this).val() == ‘تحويل بنكي’) {
  else if ($(this).val() == ‘Pay Pal’) {






in functions.php

add_action(‘wp_ajax_showPayPalAfterRev’, ‘showPayPalAfterRev’);

function showPayPalAfterRev() {
    echo $_POST[‘payactiveh’];
    if($_POST[‘payactiveh’]==’نقدا بالفندق’){
 update_option( booking_paypal_is_active, Off );   
    }elseif($_POST[‘payactiveh’]==’تحويل بنكي’){
 update_option( booking_paypal_is_active, Off );           
    }elseif($_POST[‘payactiveh’]==’Pay Pal’){
 update_option( booking_paypal_is_active, On );           



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s