1

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 :)

1
  • You have to use ajax for this Commented Aug 13, 2012 at 10:46

2 Answers 2

1

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);

        }
    });
Sign up to request clarification or add additional context in comments.

Comments

0

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/

1 Comment

Of course you may always use native JS methods for AJAX: w3schools.com/ajax/ajax_intro.asp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.