简体   繁体   中英

data from php echo inside jquery `if` statement

function(data, textStatus, jqXHR) {
    $("#info").html(data);
    if ((data).substr(0, 5)=="Please") {$("#imgOk").fadeIn();} // doesn't work

data is is php echo from another page. It is successfully placed into div #info and it's content is:
Please, check your Inbox .

Assuming data is fine, substr 's second parameter is the amount of characters to retrieve, not the ending index. As "Please" is 6 letters, it should be .substr(0, 6) .

See http://www.w3schools.com/jsref/jsref_substr.asp for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM