Could you tell me how the variables passed by php to js cannot be determined?

Source: Internet
Author: User
Could you tell me how the variables passed by php to js cannot be judged to use the ajax callback function? when the value sent by php is = 1, when the js alert succeeds, the js alert fails at 2?
However, when the callback function determines msg = 1, alert fails no matter what js value is sent.

 


Js .......................

$ (Document ). ready (function () {$ ("# login "). bind ("mouseover", login); function login () {var name = $ ("# username "). val (); var password = $ ("# password "). val (); var param = {"name": name, "password": password}; if (name = "") {alert ("Warning! Illegal access, username is blank "); return false;} else {if (password =" ") {alert (" Warning! Illegal access, password blank ") return false;} else {$. ajax ({type: "post", url: "http: // localhost/kkc/login. php ", data: param, success: function (msg) {if (msg = 1) {alert (" successful ");} else {alert ("failed ");}}});}};};});


Reply to discussion (solution)

It should be the impact of the BOM header.

Echo base64_encode (file_get_contents ('http: // localhost/kkc/login. php '));
Post result

Use chrome to check what the php file returns and see if there are any other problems.

Echo base64_encode (file_get_contents ('http: // localhost/kkc/login. php '));
How can I solve the problem after posting the results...

You have not done what I want!
How can I give you the next step?

Do you want me to fool you ???

You have not done what I want!
How can I give you the next step?

Do you want me to fool you ???

I have removed the bom header. how can I do it next? I am the first time I did java, but I don't understand php...

Isn't there require ("mysql. php?
Is the BOM header removed from mysql. php?

Java is not a shield, because it is basic knowledge.

Isn't there require ("mysql. php?
Is the BOM header removed from mysql. php?

Java is not a shield, because it is basic knowledge.
Okay, but no such issues have occurred in the j2ee project.

Success: function (msg ){
Alert (msg); // check what is prompted
If (msg = 1 ){
Alert ("successful ");
} Else {
Alert ("failed ");
}

Success: function (msg ){
Alert (msg); // check what is prompted
If (msg = 1 ){
Alert ("successful ");
} Else {
Alert ("failed ");
}
If the account is correct, 1 Fails. 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.