My task is to post selected autocomplete value from index.php
to test.php
.I need to return data to index.php
as a variable not an output.I think I need to use php CURL
.But I don't get any positive result yet.
index.php:
select: function(event, ui)
{
selected=ui.item.value;
jQuery.ajax({
url:"test.php",
data:{selected},
type:"POST",
success:function(data){
}
</script>
<?php
if(isset($response)){
echo $response;
}
test.php:
if(isset($_POST["selected"])){
$selection1=$_POST["selected"];
$url=mysite.com/index.php";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $selection1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
}
?>