0

i'm trying to pass jQuery variable to my codeigniter view through controller. i have some input fields in my form but i dont want the input fields values to be captured in my controller method.

<form action="controller_name/method_loading_view" method="get">
  //input fields
  <input type="submit" onclick='myFunction()' /> 
</form>

<script type="text/javascript">
    function myFunction(){
            var code=128;
            var qty=10;
            var base_url='http://localhost/sitename/';
                $url = base_url+'controller_name/method_loading_view';
                $.get($url, {pcode: this.code, pqty: this.qty});
              }   
</script>

and then i'm trying to get the values in my codeigniter method with $_GET

$code = $_GET['pcode'];
$qty = $_GET['pqty'];
2
  • $_GET['qty'] should be $_GET['pqty'] Commented Jan 2, 2020 at 6:40
  • oh sorry thats a typo , i'm using pqty as well, edited Commented Jan 2, 2020 at 6:44

1 Answer 1

2

You have defined 'var code=128; var qty=10;' in method so no need to pass it with this.code and this.qty

Try to set it like

$.get($url, {pcode: code, pqty: qty});
Sign up to request clarification or add additional context in comments.

Comments

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.