diff --git a/ajax.php b/ajax.php index 1650d2f2..2a43d83f 100644 --- a/ajax.php +++ b/ajax.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-16 23:01:33 * @Last Modified by: prpr - * @Last Modified time: 2016-02-03 10:26:40 + * @Last Modified time: 2016-02-03 10:29:58 * * All ajax requests will be handled here */ @@ -77,20 +77,20 @@ if ($action == "login") { if (checkFile()) { if ($file = utils::getValue('skin_file', $_FILES)) { if ($user->setTexture('skin', $file)) { - $json[0]['errno'] = 0; - $json[0]['msg'] = "Skin uploaded successfully."; + $json['skin']['errno'] = 0; + $json['skin']['msg'] = "Skin uploaded successfully."; } else { - $json[0]['errno'] = 1; - $json[0]['msg'] = "Uncaught error."; + $json['skin']['errno'] = 1; + $json['skin']['msg'] = "Uncaught error."; } } if ($file = utils::getValue('cape_file', $_FILES)) { if ($user->setTexture('cape', $file)) { - $json[1]['errno'] = 0; - $json[1]['msg'] = "Cape uploaded successfully."; + $json['cape']['errno'] = 0; + $json['cape']['msg'] = "Cape uploaded successfully."; } else { - $json[1]['errno'] = 1; - $json[1]['msg'] = "Uncaught error."; + $json['cape']['errno'] = 1; + $json['cape']['msg'] = "Uncaught error."; } } } @@ -148,8 +148,8 @@ function checkFile() { $json['msg'] = 'Skin file type error.'; return false; } else { - $json[0]['errno'] = 0; - $json[0]['msg'] = 'No skin file selected.'; + $json['skin']['errno'] = 0; + $json['skin']['msg'] = 'No skin file selected.'; } } @@ -169,8 +169,8 @@ function checkFile() { $json['msg'] = 'Cape file type error.'; return false; } else { - $json[1]['errno'] = 0; - $json[1]['msg'] = 'No cape file selected.'; + $json['cape']['errno'] = 0; + $json['cape']['msg'] = 'No cape file selected.'; } } diff --git a/assets/js/user.utils.js b/assets/js/user.utils.js index 61fbf9df..cfaaa677 100644 --- a/assets/js/user.utils.js +++ b/assets/js/user.utils.js @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-01-21 13:56:40 * @Last Modified by: prpr -* @Last Modified time: 2016-02-03 10:17:30 +* @Last Modified time: 2016-02-03 10:29:24 */ 'use strict'; @@ -112,14 +112,14 @@ $("#upload").click(function(){ }, success: function(json) { console.log(json); - if (json[0].errno == 0 && json[1].errno == 0) { + if (json['skin'].errno == 0 && json['cape'].errno == 0) { showMsg("alert-success", "Successfully uploaded."); } - if (json[0].errno != 0) { - showMsg("alert-danger", "Error when uploading skin:\n"+json[0].msg); + if (json['skin'].errno != 0) { + showMsg("alert-danger", "Error when uploading skin:\n"+json['skin'].msg); } - if (json[1].errno != 0) { - showMsg("alert-danger", "Error when uploading cape:\n"+json[1].msg); + if (json['cape'].errno != 0) { + showMsg("alert-danger", "Error when uploading cape:\n"+json['cape'].msg); } } });