Js fails to send a post request to php. how can this problem be solved?

Source: Internet
Author: User
Js fails to send the post request to php. the function & nbsp; alertWin (title, & nbsp; msg, & nbsp; w, & nbsp; h) & nbsp ;{& nbsp; & nbsp; var & nbsp; titleheight & nbsp; 22px; & nb js failed to send post request to php.
Function alertWin (title, msg, w, h ){
Var titleheight = "22px"; // window title height
Var bordercolor = "#666699"; // border color of the window
Var titlecolor = "# FFFFFF"; // The Title color of the window.
Var titlebgcolor = "#666699"; // The background color of the window title
Var bgcolor = "# FFFFFF"; // content background color
Var iWidth = document.doc umentElement. clientWidth; // The width of the window.
Var iHeight = document.doc umentElement. clientHeight; // The height of the window.
// Create a pop-up layer
Var msgObj = document. createElement ("p ");
// Set the pop-up layer style
MsgObj.style.css Text = "position: absolute; font: 11px ''; top:" + (iHeight-h)/2 + "px; left:" + (iWidth-w) /2 + "px; width:" + w + "px; height:" + h + "px; text-align: center; border: 1px solid" + bordercolor + "; background-color: "+ bgcolor +"; padding: 1px; line-height: 22px; z-index: 1001 ;";
Document. body. appendChild (msgObj );
// Create a table to accommodate content on the layer
Var table = document. createElement ("table ");
// Place the Table on the pop-up layer
MsgObj. appendChild (table );
// Set the table format
Table.style.css Text = "margin: 0px; border: 0px; padding: 0px ;";
Table. cellSpacing = 0;
// Insert a row to display the title
Var tr = table. insertRow (-1 );
// Insert a cell to hold the title
Var titleBar = tr. insertCell (-1 );
TitleBar.style.css Text = "width: 100%; height:" + titleheight + "px; text-align: left; padding: 3px; margin: 0px; font: bold 13px ' '; color: "+ titlecolor +"; border: 1px solid "+ bordercolor +"; cursor: move; background-color: "+ titlebgcolor;
TitleBar. style. paddingLeft = "10px ";
// Set the title
TitleBar. innerHTML = title;
// Close button event
Var closeBtn = tr. insertCell (-1 );
CloseBtn.style.css Text = "cursor: pointer; text-align: right; padding: 2px; background-color:" + titlebgcolor;
CloseBtn. innerHTML = "× ";
CloseBtn. onclick = function (){
Document. body. removeChild (msgObj );
}
// Pop-up message window content
Var msgBox = table. insertRow (-1). insertCell (-1 );
MsgBox.style.css Text = "font: 10pt '';";
MsgBox. colSpan = 2;
MsgBox. innerHTML = msg;
Var nameBox1 = table. insertRow (-1 );
Var nameLable1 = nameBox1.insertCell (-1 );
NameLable1.style.css Text = "font: 10pt ''; text-align: center ;";
NameLable1.innerHTML ="Mobile phone*";

Var nameBox2 = table. insertRow (-1 );
Var nameLable2 = nameBox2.insertCell (-1 );
NameLable2.style.css Text = "font: 10pt ''; text-align: center ;";
NameLable2.innerHTML ="Verification code";

Var nameBox3 = table. insertRow (-1 );
Var nameLable3 = nameBox3.insertCell (-1 );
NameLable3.style.css Text = "font: 10pt ''; text-align: center ;";
NameLable3.innerHTML ="";
}

Function get_mobile_code (){
Alert ("111 ");
$. Post ('http: // '+ serverIp + 'smsexecute. php ', {mobile: jQuery. trim ($ ('# mobile '). val (), send_code: }, Function (msg ){
Alert (jQuery. trim (unescape (msg )));
});
Alert ("222 ");
}

------ Solution ----------------------
Send_code :' '}

Check that jQuery is loaded correctly.
------ Solution ----------------------
Reference:
Quote: reference:

Check whether session_start () is used. then, the key value passed in braces must be enclosed in quotation marks.

Bytes -------------------------------------------------------------------------------------------------------------
Session_start () is available. The quotation marks do not work either: {"mobile": jQuery. trim ($ ('# mobile'). val (), "send_code ": }

When you right-click to view the source code, is the php script correctly parsed? This is critical.

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.