I need to pass an ajax result with query string in php. But i don't know how to assign ajax response in php variable. My code is
<script>
function langchange()
{
var langs= $('#langs').val();
$.ajax({
type:"POST",
url:"ajax_lang_change.php",
data:"id="+langs,
success:function(value){
var data=value.split("|_,_|");
for(var i=0;i<data.length;i++){
$("#cat_desc"+i).html(data[i]);
}
}
});
}
$(window).load(function(){
langchange();
});
</script>
I have to assign this value to $lang_id and pass it in the following query
<a href="category.php?c_id=<?php echo $row['id']; ?>&lang_id=<?php echo $lang_id;?>"></a>
ajax-language_change.php
<?php
include 'db_connect.php';
$id = $_POST['id'];
$result = mysqli_query($link, "SELECT * FROM category AS c INNER JOIN category_language AS cl ON c.id=cl.category_id where parent_id IS NULL && lang_id='$id'");
while($row=mysqli_fetch_array($result))
{
echo $row['category_description']."|_,_|";
}
?>
The result of this script is captured in ajax and assigned in #cat_desc. I have to assign this in php variable $lang_id
Help??