Frage

I retrieved an object of array from my code behind(PHP) into my JQuery and get:

Array
(
    [0] => stdClass Object
        (
            [MFID] => 1
            [MFName] => Customer ID
            [FTID] => 1
            [DTID] => 1
            [MFKey] => 0
            [MFWSKey] => 
            [MFWSName] => 
            [MFRequired] => 1
            [MFDefaultValue] => 
            [MFMin] => 0
            [MFMax] => 0
            [MFDueDate] => 0
            [MFToBePaid] => 0
            [MFMaxLength] => 50
            [MFOrderNo] => 1
            [MFStatus] => 1
        )

)

I want to get the MFName from that array into a certain input object, lets say

$("#fname").val(data[0]['MFName']);

But that does not work.

Usually I do it in Php before returning it to the client,

    $val = $array[0]->MFname;

How can I do it in JQuery?

War es hilfreich?

Lösung

// return json encoded array in php side

var arr = JSON.parse(yourArray);
alert(arr[0].MFname); 

Hope you will find using this

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top