Can anyone provide a simple example of running a controller action in the background when a button is clicked.
eg: when this is clicked:
<button onclick="startprocess">Start</button>
run
this->actionStartScript('10.5.5.1');
Thanks
Can anyone provide a simple example of running a controller action in the background when a button is clicked.
eg: when this is clicked:
<button onclick="startprocess">Start</button>
run
this->actionStartScript('10.5.5.1');
Thanks
If U got U right, what U need is ajax .
How? I need a example.
here you go
<button id="myButton">Click here</button>
<div id="content"></div>
<script>
// when you click on the button it will load the action response in "content" div
$("document").ready(function() {
$("#myButton").click(function() {
$("#content").load("site/myAction");
});
});
</scrip>
How i call the function:
this->actionStartScript('10.5.5.1')
hi .what do you mean??
Here is an other example
<button id="startprocess">Start</button>
<script>
$("document").ready(function() {
$("#startprocess").click(function() {
$.ajax({
type: "POST",
url: "site/StartScript", //it will call $this->actionStartScript('10.5.5.1') and site is the controller name
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
});
});
</script>
I try to execute but the method $this->actionStartScript(‘10.5.5.1’) is not executed. O controller this method is Filial1Controller.