I have a small part of the code. I have to get the data using ajax but I am getting only one field.
There is no issue with the value and I am getting the correct one. I have to send the result to ajax but I am getting only one field.
I believe there is some issue with my array.
$result=[];
if ($haschange['fb']==1) {
$result[]="<input type='text' value='".$social_links['fb']."'>";
}
if ($haschange['twitter']==1) {
$result[]="<input type='text' value='".$social_links['twitter']."'>";
}
if ($haschange['linkedin']==1) {
$result[]="<input type='text' value='".$social_links['linkedin']."'>";
}
if ($haschange['instagram']==1) {
$result[]="<input type='text' value='".$social_links['instagram']."'>";
}
echo json_encode($result);
exit();
script
<script type="text/javascript">
$(document).on('click', '.pendingContent', function(){
var id=$(this).data("id");
//alert(id);
$.ajax({
url: 'process.php',
method:'post',
dataType: "json",
data:{action:"pendingContent",id:id},
success: function(data){
$('#shaedcontent').html(data);
$("#pendingContent").modal('show');
}
});
});
</script>
My Answer:
array("fb" => $haschange['fb']);
Rate this post
4 of 5 based on 9225 votesComments