Example 14:

This example show you how to:

  • Load the plugin
  • Pass extra data to the server side

HTML :
<select id="state_id" class="mSelect" multiple="multiple"></select>
JS :
$(function () {
    $('#state_id').mSelect({
        url: 'ajax/example14.php',
        data: {'country_id': 231}  //data to pass to the server side (231 for United States)
    });
});
PHP :
<?php 
    //........
    // get the country_id passed via ajax data
    $whereAll = null; 
    if(isset($_GET['country_id']) && !empty($_GET['country_id'])){
        $whereAll = "country_id = ".$_GET['country_id']; // make sure to secure the data passed here
    }

    echo json_encode(
        Datatables::complex($_GET, $sql_details, $table, $primaryKey, $columns, $whereResult = null, $whereAll)
    );
?>