A simple record that $. getJSON does not execute

  • 2021-07-04 17:56:51
  • OfStack

Other people's code, take it and adjust it, and find that the modification function can't be used. When modifying, send json through ajax to obtain data. Look at chrome developer tools and find that there are sent data and return values;

Initiate the request and get the data, and find that the callback function does not execute!


$.getJSON(site_url+'?m=test&a=getOne',{id:id},function(d){
  if(d.status){
    vardata=d.data;
    $('input[name="id"]').val(data.id);
    $('input[name="name"]').val(data.name);
  }else{
    Message.fairue(d.info);
    setTimeout(function(){
      // todo
    },2000);
  }
});

php return data code:


if($findOne){
  $this->ajaxReturn($findOne,'success',true);
}else{
  $this->ajaxReturn($findOne,'faild',false);
}

The returned data also looks normal in the browser:

{"data":{"id":"1","name":"admin",},"info":"success","status":true}

Tuned for a long time. . .

Some people say that it is the problem of json format, some people say that it is the problem of parameters, and I am not familiar with js. After investigation, 11 are excluded. . .

When you paste the json data returned by your browser into vim, you find:

< feff > {"data":{"id":"1","name":"admin",},"info":"success","status":true}

< feff > ? ? ? bomb. . .

Attachment: vi bomb operation:


# Add BOM
:set bomb
# Delete BOM
:set nobomb
# Query BOM
:set bomb?

Find all files containing bomb in the current directory:


grep -I -r -l $'\xEF\xBB\xBF' ./

bomb and/Conf/config. php were found. . .

Project Framework: ThinkPHP


Related articles: