Reputation: 37
OnClick Event of a button the values enter by user inside Username and Password text boxes are successfully retrieved into the javaScript function, now I want to send these values to CodeIgniter controller is there any way to do it??? thanks in Advance :)
Upvotes: 1
Views: 1576
Reputation: 1979
Here is how I do it with jquery...pretty simple.
url: "<?php echo base_url('index.php/site/addItems/'); ?>",
is pointing to a function in the controller
$('#addItem').click(function(){
var id = $('#id').val();
var data = {
item: $('#itemName').val(),
price: $('#itemPrice').val(),
id: $('#id').val()
};
$.ajax({
url: "<?php echo base_url('index.php/site/addItems/'); ?>",
type: "post",
data: data,
success: function(msg) {
$('#items').html(msg);
}
});
Upvotes: 1
Reputation: 792
Yes, there is. Have a look at http://api.jquery.com/jQuery.ajax/ , http://api.jquery.com/jQuery.post/ , http://api.jquery.com/jQuery.get/
Upvotes: 0