I have got a page where visitors can use a dropdown menu to get info on a person.
After the change-call, jquery sends the ID of the person via ajax to a php-script, that pulls the data out of a database.
Because the data should be used in three different div's on the requesting page, the data is sent back as an (php) array.
And now I need your help. How can I split the array ( it has three parts ) into three javascript parts, that can be send to the specific divs (so, div1, div2 and div3)?
This is the code I have:
$('#contentz').change(function(){
var Value = $(this).val();
$.ajax({
type: 'post',
url: '/ajax.php',
dataType: 'html',
data: {action: Value},
success:function( data){
// I need to slice the array here
$("#veld1").html( data ); // result 1
$("#veld2").html( data ); // result 2
$("#veld3").html( data ); // result 3
//alert(data);
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
},
complete: function(){
//alert('update success');
}
});
});
#contentz is the select/ dropdown.
#veld1, #veld2 and #veld3 are the divs that display the result.
data?