0

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

1 Answer 1

3

You can pass javascript parameter at end like following :

window.location.href = "<?php echo site_url('sellbyitem/retrieveInfo/');?>" + oneday ;
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.