JS to send a POST request to PHP failed to solve

Source: Internet
Author: User
function Alertwin (title, MSG, W, h) {var titleheight = "22px";//Window caption height var bordercolor = "#666699";//Window The border color of the port var titlecolor = "#FFFFFF"; The title color of the window var titlebgcolor = "#666699"; Window title background color var bgcolor = "#FFFFFF"; Content background color var iwidth = document.documentElement.clientWidth; The width of this window is var iheight = document.documentElement.clientHeight;         The height of this window//creates a popup layer var msgobj = document.createelement ("div"); Set the style of the popup layer MsgObj.style.cssText = "position:absolute;font:11px"; Top: "+ (IHEIGHT-H)/2 +" Px;left: "+ (IWi DTH-W)/2 + "Px;width:" + W + "Px;height:" + H + "px;text-align:center;border:1px solid" + bordercolor + "; background-         Color: "+ bgcolor +";p adding:1px;line-height:22px;z-index:1001; ";         Document.body.appendChild (Msgobj);         Create a table to hold the content on the layer var table = document.createelement ("table");         Place the table on the pop-up layer msgobj.appendchild (table); Format the table         Table.style.cssText = "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.cssText = "Width:100%;height:" + titleheight + "Px;text-align:left;padding:3px;margin:0px;font:bold         13px ' song body '; color: "+ Titlecolor +"; border:1px solid "+ bordercolor +"; Cursor:move;background-color: "+ titlebgcolor;         TitleBar.style.paddingLeft = "10px";         Set title titlebar.innerhtml = title;         Close button event var closebtn = Tr.insertcell (-1); CloseBtn.style.cssText = "Cursor:pointer;         Text-align:right;padding:2px;background-color: "+ titlebgcolor; closebtn.innerhtml = "x";         Closebtn.onclick = function () {document.body.removeChild (msgobj);         }//Popup message window contents var MsgBox = Table.insertrow ( -1). InsertCell (-1);         MsgBox.style.cssText = "font:10pt ' song"; ";         Msgbox.colspan = 2;         msgbox.innerhtml = msg;         var nameBox1 = Table.insertrow (-1);         var nameLable1 = Namebox1.insertcell (-1);         NameLable1.style.cssText = "font:10pt ' song"; text-align:center; "; namelable1.innerhtml = "Cell phone * ";         var nameBox2 = Table.insertrow (-1);         var nameLable2 = Namebox2.insertcell (-1);         NameLable2.style.cssText = "font:10pt ' song"; text-align:center; "; namelable2.innerhtml = "Verification Code";         var nameBox3 = Table.insertrow (-1);         var nameLable3 = Namebox3.insertcell (-1);         NameLable3.style.cssText = "font:10pt ' song"; 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");}


Reply to discussion (solution)

55 lines before the code, the effect is as follows:

Then click on the 44 line "Get Phone verification Code" button, can trigger 57 lines of Get_mobile_code function, 111 and 222 can pop, but. Post does not respond.

What's wrong with you, there's too many possibilities for this information.

See if there is any session_start () and then there is the curly braces inside the value of the key is actually quoted

Page right-click on the source code to see if your variables are correctly parsed.

See if there is any session_start () and then there is the curly braces inside the value of the key is actually quoted


-------------------------------------------------------------------------------------------------------------
Session_Start () is there. The quotation marks have no effect: {"mobile": Jquery.trim ($ (' #mobile '). Val ()), "Send_code": }

Send_code: ' }

Make sure JQuery is loaded correctly

1.firebug What are the error hints?
The 2.firebug network looks at what is returned after post.


See if there is any session_start () and then there is the curly braces inside the value of the key is actually quoted


-------------------------------------------------------------------------------------------------------------
Session_Start () is there. The quotation marks have no effect: {"mobile": Jquery.trim ($ (' #mobile '). Val ()), "Send_code": }


Do you correctly parse the PHP script when you right-click on the source code? This is key.

Send_code: ' }

Make sure JQuery is loaded correctly


----------------------------------------------------------------------
Hello, by the way, ask a question, such as I used in the a.php $_session[' send_code ']= ' 123456 ', then in the b.php can be directly used $_session[' Send_code '? Or do you need to specify b.php in a.php like post?

Yes, you can use it directly
But there is a premise: Must have Session_Start (); Statement

Yes, you can use it directly
But there is a premise: Must have Session_Start (); Statement


-------------------------------------------------------------------------
Does the value of $_session[' Send_code ' always exist?

No, after closing the browser or closing the tab associated with the site, there is no

I found myself walking into a dead end.

  • 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.