Call AJAX with select onchange using jQuery

Below is the code where you can easily understand select Tag on change with ajax request using PHP.
Replace id #theme_option with yours.

HTML Code
<select class="form-control" id="theme_option">
<option value="default">Default</option>
<option value="real-estate">Real Estate</option>
<option value="dispatching">Dispatching</option>
<option value="dental">Dental</option>
<option value="medical">Medical</option>
<option value="restaurant">Restaurant</option>
<option value="consumer-product">Consumer Product</option>
</select>

Jquery code

jQuery(document).ready(function($){
    $('#theme_option').change(function(){
$.ajax({
url: "change_theme.php",
data: { "theme": $("#theme_option").val() },
type: "post",
success: function(data){
   window.location.reload();
}
});
});
});

Comments

Popular posts from this blog

Creating Protected routes in ReactJS

Redirect http to https in codeigniter