我似乎无法让.text()
函数在我的函数中正常运行。
有时,页面会正确显示,但大多数时候,文本不会改变。该页面以<p>
显示“Waiting”的标签开始,然后.text()
正常beforeSend:
工作,文本更改为“Processing request...”,但从那时起,该.text()
功能似乎不起作用。
我已经添加了console.log
s 以查看msg
变量是否被正确填充,但.text()
仍然没有<p>
第二次更改标签。在所有浏览器中似乎都是一样的。
这是我的功能:
function sendrequest(first, last, email) {
var request = $.ajax({
url:"/core/ajax/register.php",
type:"POST",
data: {uf:first,ul:last,ue:email},
beforeSend: function(){
forms.regFor.fadeOut(100, function(){
$('p#msg').text('Processing request...');
});
}
});
request.done(function(data){
var msg;
if (data == 1){
msg = "Thank you "+first+", your request has been sent.";
console.log('Registered successfully');
}else if (data == 2){
msg = "It appears that you have already signed up.";
console.log('Already signed up');
}else{
msg = "There has been an error.";
console.log('Error on submission');
}
console.log(msg);
$('p#msg').text(msg);
});
}
我可能错过了一些非常简单的东西,似乎根本看不到它,希望有人可以。