sql server - Ajax MSSQL query using json and php returns undefined array -


i have problem when alert( data[i].name). result undefined if array returned. knows problem is?

this javascript

    $('#plus').click(function(){     $.ajax({         type : 'post',         url : 'jquerydbactionview.php',         datatype : 'json',         data: { },         success: function( data){             $.each( data, function(i, item) {                 alert( data[i].name);             });         }     }); }); 

and php

$query = "select top (1) * "; $query .= "from maillist bolag = 'fal'"; $results = mssql_query($query); $result = array(); while($row = mssql_fetch_array($results)) {   $result[] = array(           'id' => $row['id'],           'company' => $row['company'],           'name' => $row['name'],           'mail' => $row['mail']        ); } echo json_encode($result); 

please use json.parse(data) convert json encoded result , use in each loop


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -