我有2个代码。
首先:
if (typeof website == 'undefined') {
window.location = "../#!404";
}
第二
function credits(){
if (!$("input[name='choices']:checked").val()) {
var choice = "5";
}
else {
var choice = $("input[name='choices']:checked").val();
}
$.ajax({
type:'POST',
url:'./core/credits.php',
data:"smscode="+$('#smscode').val()+"&choices="+choice,
success:function(response){
if(response=='1'){$('#sms_label').css({'display':'block','border':'1px solid #bfde84','background':'#edfbd8 url(../images/success.gif) 12px 12px no-repeat','color':'#508600',}).html('Успешно заредихте 1 кредит')}
else if(response=='2'){$('#sms_label').css({'display':'block','border':'1px solid #e9c59b','background':'#ffecce url(../images/error.gif) 12px 12px no-repeat','color':'#e3302c',}).html('Моля изберете колко кредита искате да заредите')}
else if(response=='3'){$('#sms_label').css({'display':'block','border':'1px solid #e9c59b','background':'#ffecce url(../images/error.gif) 12px 12px no-repeat','color':'#e3302c',}).html('Моля въведете SMS код')}
else if(response=='4'){$('#sms_label').css({'display':'block','border':'1px solid #e9c59b','background':'#ffecce url(../images/error.gif) 12px 12px no-repeat','color':'#e3302c',}).html('Въведеният SMS код е грешен или изтекъл')}
if(response=='5'){$('#sms_label').css({'display':'block','border':'1px solid #bfde84','background':'#edfbd8 url(../images/success.gif) 12px 12px no-repeat','color':'#508600',}).html('Успешно заредихте 2 кредита')}
if(response=='6'){$('#sms_label').css({'display':'block','border':'1px solid #bfde84','background':'#edfbd8 url(../images/success.gif) 12px 12px no-repeat','color':'#508600',}).html('Успешно заредихте 4 кредита')}
if(response=='7'){$('#sms_label').css({'display':'block','border':'1px solid #bfde84','background':'#edfbd8 url(../images/success.gif) 12px 12px no-repeat','color':'#508600',}).html('Успешно заредихте 6 кредита')}
}
});
}
网站变量在index.php中定义
var website = true;
两个代码在分开时工作正常,但是当我将它们合并为一个文件时。
第二个代码有效,第一个没有。