There is a handler:

$(document).delegate('#fakeButton', 'click', function() { var url = 'index.php?route=checkout/guest/freetimes'; $('#timeselect').load(url, {'date': $('#input-payment-orderdate').val()}); }); 

and function in php:

 function freetimes() { $myCurl = curl_init(); $date = $_POST('date'); curl_setopt_array($myCurl, array( CURLOPT_URL => "http://localhost:56987/api/orders/freetimes?date=".$date, CURLOPT_RETURNTRANSFER => true )); $response = curl_exec($myCurl); curl_close($myCurl); $times = array(); $times[] = split("/", str_replace("\"","",$response)); $rez = ''; $max = sizeof($times[0]); for ($i = 0; $i < $max; $i++) { list($value, $start, $end) = split('-', $times[0][$i]); $rez = $rez.'<option value="'.$value.'">'.$start.'-'.$end.'</option>'; } echo $rez; } 

The php function is fully working and with $ date = date ("Ynj") works great, but when you try to accept parameters using the POST method, it crashes.

I do not know how to fix

    1 answer 1

    http://api.jquery.com/load/

    It is roughly equivalent to $ .get (url, data, success)

    [roughly corresponds to $ .get (url, data, success)]

    That is, in the load GET request, not POST. Or change the php code to

     $date = $_GET['date']; (а то и $_REQUEST['date']) 

    or use

     $.ajax({ type: "POST", url: "index.php?route=checkout/guest/freetimes", data: { 'date': $('#input-payment-orderdate').val() }, dataType: "html", success: function(data) { $('#timeselect').html(data); } });