fix ajax urls at skinlib

This commit is contained in:
printempw 2016-09-10 21:37:00 +08:00
parent b455fe6f06
commit 97539d4178

View File

@ -2,11 +2,13 @@
* @Author: printempw * @Author: printempw
* @Date: 2016-07-19 10:46:38 * @Date: 2016-07-19 10:46:38
* @Last Modified by: printempw * @Last Modified by: printempw
* @Last Modified time: 2016-09-10 17:07:04 * @Last Modified time: 2016-09-10 21:36:10
*/ */
'use strict'; 'use strict';
var base_url = location.pathname.endsWith('skinlib') ? "." : "..";
$(document).ready(function() { $(document).ready(function() {
swal.setDefaults({ swal.setDefaults({
confirmButtonText: '确定', confirmButtonText: '确定',
@ -36,7 +38,7 @@ $('#type-skin').on('ifToggled', function() {
}); });
function addToCloset(tid) { function addToCloset(tid) {
$.getJSON('./info/'+tid, function(json) { $.getJSON(base_url + '/skinlib/info/'+tid, function(json) {
swal({ swal({
title: '给你的皮肤起个名字吧~', title: '给你的皮肤起个名字吧~',
inputValue: json.name, inputValue: json.name,
@ -66,7 +68,7 @@ function ajaxAddToCloset(tid, name) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "../user/closet/add", url: base_url + "/user/closet/add",
dataType: "json", dataType: "json",
data: { 'tid': tid, 'name': name }, data: { 'tid': tid, 'name': name },
success: function(json) { success: function(json) {
@ -98,7 +100,7 @@ function removeFromCloset(tid) {
}).then(function() { }).then(function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "../user/closet/remove", url: base_url + "/user/closet/remove",
dataType: "json", dataType: "json",
data: { 'tid' : tid }, data: { 'tid' : tid },
success: function(json) { success: function(json) {