The Ajax return value enters the ShowMsg function, and then alert (tips) out of the value returned by the function, but the total display of undefined, is not the question of return type, novice ask ~
function ShowMsg (MS)
{
var tips
Switch (MS)
{
Case ' ding ':
tips= ' thanx votting ';
Break
Case ' Cai ':
Tips= ' thanx u done ';
Break
Case ' Erro ':
tips= ' 404 NotFound ';
Break
default:tips= ' Erro ';
Break
}return tips;
}
Reply to discussion (solution)
Syntax error, the previous two break missing the ending semicolon, first filled. Then read the newspaper under the Firebug console what's wrong.
Alert (MS) at the entrance of the function to see what's coming in
JS does not enforce the need for line Terminator ";"
Alert (MS) at the entrance of the function to see what's coming in
JS does not enforce the need for line Terminator ";"
In fact, I see in the Firebug Ajax returned more than 2 spaces, but the front I use regular expression is cleared, but the remaining two empty Ge Qing, can not be completely cleared. The return is "1", not "1".
var Str=xmlhttp.responsetext;
var pass= str.replace (/\r\n/g, "");
Syntax error, the previous two break missing the ending semicolon, first filled. Then read the newspaper under the Firebug console what's wrong.
In fact, I see in the Firebug Ajax returned more than 2 spaces, but the front I use regular expression is cleared, but the remaining two empty Ge Qing, can not be completely cleared. The return is "1", not "1".
var Str=xmlhttp.responsetext;
var pass= str.replace (/\r\n/g, "");
var pass= str.replace (/\s+/g, ""); This is the clear space, your that is clear change line
var pass= str.replace (/\s+/g, ""); This is the clear space, your that is clear change line
You are right to say ~ ~ didn't learn well