dongmaqiu6084 2017-08-02 01:46
浏览 62


I am kinda lost as to why I cant get data passed

getValues: function(url) {
    var result = null;
    url: url,
    type: 'get',
    dataType: 'json',
    async: false,
    success: function(data) {

        result = JSON.stringify(data);

return result;

I have no problems with the js part the problem is the php

$sql = "SELECT name, score FROM scores ORDER BY score DESC LIMIT 10 ";
$result = mysqli_query($conn1, $sql);
if (mysqli_num_rows($result) > 0) {
$data = array(); 
while ($row = mysqli_fetch_assoc($result)) {
    $data[] = array("name"=>$row['name'], "score"=>$row['score']);
    $post_data = json_encode(array($data));
echo $post_data;

echoing post data gives nothing if i echo post data inside while loop i get a result for every iteration of while loop. If i print_r data array i also get some kind of result. My question is what am i doing wrong?
Thank you for your answers I did bring out post data from the loop that was poorly made indeed however the real problem was that one of the names was in russian alphabet and the result from database wasnt utf-8

  • 写回答

3条回答 默认 最新


      相关推荐 更多相似问题


      • ¥15 fluent计算后处理中如何把质量分数和摩尔分数转化为体积分数
      • ¥20 asn1c编码问题,懂asn1的人很简单
      • ¥60 在排球比赛中,排球落于界限上时,人工判断存在一定的主观因素。利用图像处理的方法来计算排球落点相对界限中心位置,判断结果。
      • ¥15 使用vs2019开发的动态链路库在win7环境下使用有问题
      • ¥30 quartus prime画电路图,要发源文件和电路图每个模块批注,源程序和仿真结果
      • ¥15 MFC滚动条如何正确使用
      • ¥15 缓冲区算法求面积,基于文献
      • ¥50 电路PCB原理图设计AD19
      • ¥15 openstack 云平台搭建 创建实例错误
      • ¥15 联想笔记本网页加载突然出了问题不知道什么原因