PHP JSON Returns u0000
PHP JSON Returns u0000
当我尝试通过Ajax从数据库中获取数据时,PHP返回以下内容:
{"readyState":4,"responseText":"'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000'u0000array(4) {'n ['"USR_ID'"]=>'n string(1) '"1'"'n ['"PLT_ID'"]=>'n string(1) '"1'"'n ['"NRS.ID'"]=>'n string(1) '"1'"'n ['"url'"]=>'n string(59) '"http://remcocr9.nine.axc.nl/tones/music/ontopoftheworld.mp3'"'n}'n","status":200,"statusText":"OK"}
这是我的PHP代码:
<?php
class Playlist
{
public function getPlaylists( $link, $song, $usrid )
{
$playlists = $link->query( "SELECT * FROM TO_PLT WHERE USR_ID = " . $usrid . ";" );
if( $playlists->num_rows ) // 1 or more playlists were found
{
while( $playlist = $playlists->fetch_assoc( ) )
{
// echo an opening DIV containing the playlist name etc via json
$data = $song->getSong( $link, $playlist[ "PLT_ID" ], $usrid);
// echo json_encode($data);
var_dump($data);
// echo json_encode($playlist); // Return playlist data
// echo a closing DIV tag via JSON so the playlist DIV is closed
}
}
else
{
// no playlists were found
}
}
}
?>
这是我用来获取数据的javascript/ajax代码:
function ajaxRequest() {
$.ajax({
type: "GET",
url: hostURL + "users.php",
dataType: 'json'
}).done(function (data) {
console.log(JSON.stringify(data));
}).fail(function (data) {
console.log(JSON.stringify(data));
});
}
该函数由 Ajax 函数调用,如何摆脱'u0000
? 还是我的代码中有另一个错误导致这种情况?
PHPStorm 杀死了我的代码,它在我的代码结束后添加了大量 NULL 文本,这在 PHPStorm 中是看不到的,但是当我在 Sublime 文本编辑器中打开文件时,它向我显示了 NULL 文本/标签。
相关文章:
- parseInt("08") returns 0
- JavaScript returns [object Object]
- Javascript imageData returns array of 0's
- HTML Javascript getElementById for <img> image returns
- $('#select').val() returns UNDEFINED
- Flickr api returns data fail() jquery
- Javascript Timer returns NaN
- node-mysql connection.query() returns undefined
- Firefox-SDK contentScript returns null
- Angular $q.defer() returns Object{then: function}
- document.getElementById(#mapid) returns null
- JavaScript getElementById returns null
- Phonegap: Camera.getPicture only returns NATIVE_URI
- Javascript returns [object HTMLSpanElement]
- Javascript eval(0047) returns 39
- localStorageService.set returns "isUndefined is not def
- jQuery $("body").height() returns undefined
- Meteor cursor.fetch().property returns "undefined"
- C# DateTime to Javascript parse returns
- PHP JSON Returns u0000