javascript - Same type of data once called is a JSON Object but when called 2nd time it turns out to be a string -
is done after my js code.
function showresult (data) {jQuery.each (data, function (key, value) {var number = 1; if (key == 0) {jQuery.each (value, function Key, value) {var str = value.split (','); jQuery.each (str, function (key, value1) {eval ("document.getElementById (''.) Src = '' + value1 + Count "++"; ';';); Count ++;});});} If (key == 1) {var calculation = 1; jQuery.each (value, function (key, value) {jQuery .each (value, work (key, value 1) {jQuery ('# image' + count) .after (value1 +% '); Count ++;});});}}); }
When I alert
, I get [object]
, passing the following data I am Function
[["Path": "patternimages / 041929_d.jpg, patternimages / 016630_d.jpg, patternimages / 039462_d.jpg, patternimages / 065862_d.jpg, patternimages / 041984_d.jpg, patternimages / 041931_d.jpg, patternimages / 041939_d.jpg, patternimages / 075066_d.jpg "}, {" percentage ": [" 100 "," 100 "," 99 "," 98 "," 98 "," 97 "]}]
When another call is made on the same function, but with different data, after alert (data)
gives me the following results: after the warning [object object]
was hoping, but after the warning I did not find the type of result
[["Path":. "Patternimages / 051696_d. Jpg, patternimages / 026965_d.jpg, patternimages / 047889_d.jpg, patternimages / 050544_d.jpg, patternimages / 019186_d.jpg, patternimages / 005978_d.jpg, patternimages / 044707_d.jpg, patternimages / 045949_d.jpg, patternimages / 104967_d.jpg, patternimages / 006135_d.jpg, patternimages / 006897_d.jpg, patternimages / 017471_d.jpg "}, {" percent ": [" 83 "," 83 "," 80 "," 80 "," 65 " , "63", "63", "63", "62", "59", "59", "51"]}].
The following is my PHP code
public function results ($ result) {$ results = array (); While ($ line = mysql_fetch_array ($ result)) {$ id [] = $ line ['image_id']; $ Percent [] = $ line ['percent']; } If (amount ($ id) & gt; 1) {$ id = array_unique ($ id); } And {@ $ id = $ id; } $ Fresult = $ this- & gt; GetResult ($ ID); $ Count = mysql_num_rows ($ frustrated); If ($ count> 1) {while ($ row = mysql_fetch_array ($ fresult)) {$ id =] = $ line ['id']; $ Name [] = $ line ['name']; $ Percent [] = $ line ['percent']; } $ Percent_val = array (); $ Res = implode (', patternimages /', $ name); $ Path ['path'] = 'pattern image /' $ race; $ Percent_language ['percent'] = $ percent; Array_push ($ result, $ path); Array_press ($ result, $ percent_value); } And {$ result = 'no data found'; } Returns $ results; }
The result is encoded to JSON response echo json_encode ($ result, JSON_UNESCAPED_SLASHES);
Edit JS code
$ .ajax ({type: 'post', datatype: "json", uRL: that uRL, data: { Colors 1: color1}, success: function (data) {showresult (;)}});
Comments
Post a Comment