How can I show another view of Controller using Ajax/Javascript when clicking a button? I attempted something, but it's not working as expected.
Javascript:
<script>
$(document).ready(function(){
$("#details").click(function(){
$( "#result" ).load( "<?php echo base_url("orders/viewDetails"); ?>" );
});
});
</script>
View:
<button id="details" href="#" class="btn btn-info"><i class="fa fa-check"></i> Show Order Items Details</button>
<div id="result"></div>
The above code snippet isn't functioning properly. How should I modify it to make it work correctly?
Previously, I had a successful implementation for "select input". How can I adapt that code for a button click event?
Javascript:
<script type="text/javascript>
function showInfo(str){
$.ajax({
type: "POST",
data: { cusId: str },
url: "<?=base_url('vehicles/getInfo');?>",
success: function(data) {
$('#divInfo').html(data);
}
});
}
</script>
View:
<select onChange="showInfo(this.value);" class="js-example-basic-single" name="docFileDocType" required="required">