1
코드를 트리거하지 않습니다jQuery를 성공은 내가 PHP에서 다음 코드를 200
$servername = "***";
$username = "***";
$password = "***";
$dbname = "***";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "select * from `opencartdb`.`oc_design` where name='mydesign '";
$res=$conn->query($sql);
$records=$res->fetch_assoc();//success
$result2=$records['info'];// already json
$conn->close();
echo ($result2);
그리고 난 다음 JS 그것을 잡으려고 : 내가 1 에게 경고를 참조하십시오 결국
jQuery.ajax({
dataType: "json",
url: "ajax.php?type=loadDesign&user_id="+user_id+"&design_id="+key
}).success(function(data) {
alert(0);
console.log((data));
}).always(function(){
alert(1);
});
을 디버거가 다음 결과를 표시합니다. 응답 :
{"vectors":"{"front":{"0":{"type":"text","width":"55px","height":"27px","top":"151px","left":"86px","zIndex":"1","svg":"<svg width=\"54.9375\" height=\"27.09375\" viewBox=\"0 0 54.9375 27.09375\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><g id=\"0.5646970888306251\"><text fill=\"#FF0000\" stroke=\"none\" stroke-width=\"0\" stroke-linecap=\"round\" stroke-linejoin=\"round\" x=\"\" y=\"\" text-anchor=\"start\" font-size=\"24px\" font-family=\"arial\" data-textcurve=\"1\" data-itemzoom=\"1 1\" data-textspacing=\"0\"><textPath xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"http://138.68.62.219/Design-Apple-T-shirt-PC55#textPath-item-0\"><tspan dy=\"0\">Hello</tspan></textPath></text></g><defs><path id=\"textPath-item-0\" d=\"M 0.125 22.117808976867764 A 3093.9720937064453 3093.9720937064453 0 0 1 54.124314613414626 22.117808976867764\"></path></defs></svg>","rotate":0,"text":"Hello","color":"#FF0000","fontFamily":"arial","align":"center","outlineC":"none","outlineW":0}},"back":{}}","teams":"{}","fonts":"","design_id":"1475007569235335440","image":"uploaded/2016/09/design-1475007569235335440.png","parent_id":"0","product_id":"178","product_options":"000000","title":"","description":""}
이 라인은 debugge에 그려진 : 응답 유형 PHP에서 JSON으로 설정
<svg width=\"54.9375\...
그래'헤더 :
또한 BOM을 피하기 위해 캐릭터 세트를 추가해야 또한 내 json에서 오류를 발견'$ result2 = str_replace (' "{', '{$ result2}, \t \t $ result2 = str_replace ('} '', '}', $ result2); ''vectors ":"{ "front":' – tttaaabbb
json_encode를 사용하는 것이 좋습니다. json_encode는 json이 유효하지 않은 경우 오류를 던집니다. 문제를 해결하는 데 도움이된다면 올바른 답을 설정하십시오. –