js向php發送post請求失敗,求解
function alertWin(title, msg, w, h) {
var titleheight = "22px"; // 視窗標題高度
var bordercolor = "#666699"; //視窗的邊框顏色
var titlecolor = "#FFFFFF"; // 視窗的標題顏色
var titlebgcolor = "#666699"; // 視窗的標題背景色
var bgcolor = "#FFFFFF"; // 內容背景色
var iWidth = document.documentElement.clientWidth; //這個視窗的寬度
var iHeight = document.documentElement.clientHeight; //這個視窗的高度
//建立一個彈出層
var msgObj = document.createElement("div");
//設定彈出的層的樣式
msgObj.style.cssText = "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);
//建立一個table用於容納層上的內容
var table = document.createElement("table");
//將Table放到彈出層上
msgObj.appendChild(table);
//設定table的格式
table.style.cssText = "margin:0px;border:0px;padding:0px;";
table.cellSpacing = 0;
//插入一行用於顯示標題
var tr = table.insertRow(-1);
//插入一個儲存格用於容納標題
var titleBar = tr.insertCell(-1);
titleBar.style.cssText = "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";
//設定標題
titleBar.innerHTML = title;
//關閉按鈕事件
var closeBtn = tr.insertCell(-1);
closeBtn.style.cssText = "cursor:pointer; text-align:right;padding:2px;background-color:" + titlebgcolor;
closeBtn.innerHTML = "×";
closeBtn.onclick = function() {
document.body.removeChild(msgObj);
}
//彈出的訊息視窗內容
var msgBox = table.insertRow(-1).insertCell(-1);
msgBox.style.cssText = "font:10pt '宋體';";
msgBox.colSpan = 2;
msgBox.innerHTML = msg;
var nameBox1 = table.insertRow(-1);
var nameLable1 = nameBox1.insertCell(-1);
nameLable1.style.cssText = "font:10pt '宋體';text-align:center;";
nameLable1.innerHTML = "手機 * ";
var nameBox2 = table.insertRow(-1);
var nameLable2 = nameBox2.insertCell(-1);
nameLable2.style.cssText = "font:10pt '宋體';text-align:center;";
nameLable2.innerHTML = "驗證碼";
var nameBox3 = table.insertRow(-1);
var nameLable3 = nameBox3.insertCell(-1);
nameLable3.style.cssText = "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");
}
------解決思路----------------------
send_code:''}
確認 jQuery 載入無誤
------解決思路----------------------
引用:
Quote: 引用:
看看有沒有session_start() 再有就是大括弧裡面傳值實際上索引值要用引號的
-------------------------------------------------------------------------------------------------------------
session_start()是有的。加了引號也沒效果:{"mobile":jQuery.trim($('#mobile').val()),"send_code":}
你在右鍵查看源碼的時候那個php指令碼正確解析了嗎?這個很關鍵