Klapsius Klapsius - 1 year ago 85
Javascript Question

value missing on AJAX response

I can't find what the error is in an AJAX call.

I have a PHP file output:

[{"value":"123","name":"My Name"}]

and this output is correct. And my AJAX call returns
after success:

type: "POST",
url: "correct_file_location.php",
data: $(this.form).serialize(),
dataType: "json",
success: function (pk) {
error: function (){

Answer Source

Since the result is an array of objects, you need to first get the object from the array, and then access the properties of that object.


should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download