Reputation:
I need to call a controller from javascript. I've already success to call the controller, but if the controller has no paramater. In my cases, the controller has a parameter. How can i can call the controller from javascript
Javascript code:
<script language="javascript" type="text/javascript">
var thisTable = setFilterGrid("myTable");
document.getElementById("oneday").onclick = function() {
var date = new Date();
var day = date.getDate().toString();
var month = date.getMonth().toString();
var year = date.getFullYear().toString();
var oneday = day.concat('/', month, '/', year);
window.location.href = "<?php echo site_url('sellbyitem/retrieveInfo('/*howcanipassonedayhere*/');?>";
};
Controller:
public function retrieveInfo($date) {
echo $date;
}
I've already looking for same cases, but it doesn't work for me
Upvotes: 0
Views: 742
Reputation: 16436
You can pass javascript parameter at end like following :
window.location.href = "<?php echo site_url('sellbyitem/retrieveInfo/');?>" + oneday ;
Upvotes: 3