Ajax call In rails 4
AJAX:
------------
AJAX is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page.
Ajax is not a programming language or a tool, but a concept.
Ajax-Asynchronous JavaScript and XML. “Asynchronous” means that multiple events are happening independently of one another
Syntax:
index.html.erb
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
function react(){
$.ajax({
type: 'GET',
url: '/home/catch_ajax_parms',
dataType: 'json',
data: { 'cp' : 100, 'cc' : 200}
});
}
</script>
</head>
<button id='clcik1' onclick="react()">hello</button>
home_controller.rb
def catch_ajax_parms
@cp = params[:cp]
@cc = params[:cc]
end
------------
AJAX is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page.
Ajax is not a programming language or a tool, but a concept.
Ajax-Asynchronous JavaScript and XML. “Asynchronous” means that multiple events are happening independently of one another
Syntax:
index.html.erb
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
function react(){
$.ajax({
type: 'GET',
url: '/home/catch_ajax_parms',
dataType: 'json',
data: { 'cp' : 100, 'cc' : 200}
});
}
</script>
</head>
<button id='clcik1' onclick="react()">hello</button>
home_controller.rb
def catch_ajax_parms
@cp = params[:cp]
@cc = params[:cc]
end
Comments
Post a Comment