The background transmits json data to the foreground, but it can not be converted into json data and receives it using ajax. Receive normal, convert abnormal QAQ

I have the ability to pass json data using ajax background

clipboard.png
json

json
HiJsonjson
clipboard.png
bejson

clipboard.png

html

clipboard.png

clipboard.png
ajax

clipboard.png
Ajax code is as follows

$(function(){
    var mydata;
    var mydata2;
    var period;
    $.ajax({
        type : "GET",
        url : "homeAction_generateRecentData.action?recentDate=7",
        dataType:"JSON",
        success: function(data){
            mydata = JSON.parse(data.data.loginTimeJson);
            mydata2 = JSON.parse(data.data.registerTimeJson);
        },
        complete:function(){
            $("-sharpindexLoading").css("display","none");
            $("-sharpperiod").text(period);
            initECharts(data,data2);
        },
        error:function(){
            $("-sharpindexLoading").html("");
        }
    });
    
});

I am puzzled!

also hope all kinds of immortals to help! Thank you very much!


use $.parse to transfer, JSON.parse has to go to the strict json form, that is, key values must be enclosed in quotation marks before the conversion can be successful, except for arrays, except true,null.


mydata = JSON.parse (data) .data.loginTimeJson;
mydata2 = JSON.parse (data) .data.registerTimeJson;


    success: function(res){
        mydata = JSON.parse(res.data.data.loginTimeJson);
        mydata2 = JSON.parse(res.data.data.registerTimeJson);
    },

first you need to print out the data, to facilitate analysis


Thank you for all the immortals, because I put initECharts (data,data2); put it in the success in the wrong place
clipboard.png
and I

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43de2-44a79.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43de2-44a79.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?