[英]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. data
是来自另一个页面的php echo。 It is successfully placed into div #info
and it's content is: 它已成功放入div
#info
,其内容为:
Please, check your Inbox
. Please, check your Inbox
。
Assuming data
is fine, substr
's second parameter is the amount of characters to retrieve, not the ending index. 假设
data
很好,则substr
的第二个参数是要检索的字符数,而不是结尾索引。 As "Please" is 6 letters, it should be .substr(0, 6)
. 由于“ Please”为6个字母,因此应为
.substr(0, 6)
。
See http://www.w3schools.com/jsref/jsref_substr.asp for more info. 有关更多信息,请参见http://www.w3schools.com/jsref/jsref_substr.asp 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.