YVS1102 YVS1102 - 1 year ago 38
jQuery Question

Receive array from ajax request

Good day, Please check my script first.

$(document).ready(function() {

$("#findmynip").click(function() {
$("#hasilnip").html('<img src="<?=base_url();?>assets_global/images/loader.gif">&nbsp; Please wait');
var nipnnya = $("#nipnya").val();
type: "POST",
data: {
nip: nipnnya
datatpe: 'json',
url: "<?=base_url();?>registrasi/cek_ada/",
success: function(hslnip) {
if (hslnip) {
//How do i do this
} else {

return false;

What i want to is receive the ajax request to my html.

When i try to
the result is
{"FullName":"BUNGA","BirthDate":"1994-10-03 00:00:00.000"}
. Any help would be appreciated.

What i want to receive is

<div id='name'></div>
<div id='birthday'></div>

I made typo at this part :
datatpe: 'json',
and i change it to
dataType: 'json'
. It's working now, thans for helping guys.


You cannot remove an array in your situation. You can use It do build an HTML content which can be displayed in hasilnama element.

Change this:


To this for example:

$("#hasilnama").html('<span>Fullname: ' + hslnip.FullName + '</span><br><span>Birthdate: ' + hslnip.BirthDate.substring(0, 10) + '</span>');