H
H
hardwellZero2015-03-09 11:50:28
JavaScript
hardwellZero, 2015-03-09 11:50:28

How to pass a variable to the server using JS?

There is such a function.

<script type="text/javascript">
   	function update_rating(id) 
   	{
   		    alert(id)
    }
  </script>

and here is the button
<button class="btn btn-primary" onclick="update_rating({{ comment.id }})">Try it</button>

You need to pass a variable to use it in views (route)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Shikanov, 2015-03-09
@dizballanze

ajax

I
Ilya Suhodolskiy, 2015-03-09
@suhodolskiy

$.ajax({
  url: '/path/to/file',
  type: 'default GET (Other values: POST)',
  dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
  data: {param1: 'value1'},
});

Ajax request - jQuery

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question