php - pass complex text to JQuery -
i have ran strange behavior of passing json php jquery.
i have articles (drupal cms articles) , need push them environment. first solution worked, while articles pushed directly php on page load. work works more 1 cms, takes time load them all, need use ajax load 1 specific project @ time.
now, jquery looks this:
function doloadarticles() { (var = 0; i< projectdata[1].length; i++){ $.ajax({ data: {ip:projectdata[0]["ip"], login:projectdata[0]["login"], pass:projectdata[0]["pass"], db:projectdata[0]["db"], datatype:projectdata[1][i], aj:"aj", fc:"doloadarticles"}, type: "post", url: "datafunnel.php", success: function(data){ console.log(data); //console.log(jquery.parsejson( data )) ; } }); } }
then, on php side code:
function doloadarticles(){ $projdata; $conn = new mysqli($_post['ip'], $_post['login'], $_post['pass'], $_post['db']); // check connection if ($conn->connect_error) { die("<div style='position:absolute; top:0;left:0; background:white;'>connection failed: " . $conn->connect_error." <br><br>plese try reload page</div>"); break; } else{} $sql = "select node_revision.title, node_revision.nid, node.language, field_revision_body.body_value, field_revision_body.bundle, node_revision.timestamp field_revision_body left join node_revision on field_revision_body.revision_id=node_revision.vid left join node on field_revision_body.revision_id=node.vid field_revision_body.bundle='".$_post['datatype']."' , node_revision.status=1 , node.language='cs' order field_revision_body.revision_id desc limit 10"; $result = $conn->query($sql); if ($result->num_rows > 0) { // error_log("true"); // output data of each row $j =0; while($row_a = $result->fetch_assoc()) { $projdata[$j]["title"] = $row_a["title"] ; $projdata[$j]["timestamp"] = $row_a["timestamp"] ; $projdata[$j]["bundle"] = $row_a["bundle"] ; $projdata[$j]["body_value"] = $row_a["body_value"]; $projdata[$j]["nid"] = $row_a["nid"]; $projdata[$j]["language"] = $row_a["language"]; $j++; } } echo json_encode($projdata); }
the problem is, data there, passing not work .. (probably because of buged conversion?)
if do
echo print_r($projdata);
pass data, not in usable way (ignore broken chars, not related problem, data thare, matters)
however, clear, need in form can work with, need json. if use
echo json_encode($projdata);
so there mistake not aware of, or kind of bug in php implementation? (by way, run on php 5.6 on ms iis7)
or other way possible, how load data dynamically without json conversion?
thanks in advance
Comments
Post a Comment