layer弹出层提交表单
我使用layer弹出层" title="layer弹出层">layer弹出层 ajax提交表单时 url出现问题 list.do是我点击弹出层时的url
//弹出一个页面层 $('#addCustomer').on('click', function(){
layer.open({
type: 1,
area: ['800px', '600px'],
shadeClose: false, //点击遮罩关闭
content: '<form class="am-form">\n' +
' <br>\n' +
' <label for="username">姓名:</label>\n' +
' <input type="text" name="name" id="name"/>\n' +
' <br>\n' +
' <label for="username">账号:</label>\n' +
' <input type="text" name="username" id="username"/>\n' +
' <br>\n' +
' <label for="password">密码:</label>\n' +
' <input type="password" name="password" id="password"/>\n' +
' <br>\n' +
' <label for="password">手机号:</label>\n' +
' <input type="text" name="phone" id="phone"/>\n' +
' <br>\n' +
' <label for="password">找到密码问题:</label>\n' +
' <input type="text" name="phone" id="question"/>\n' +
' <br>\n' +
' <label for="password">找到密码问题:</label>\n' +
' <input type="text" name="phone" id="answer"/>\n' +
' <div class="am-cf">\n' +
' <input type="submit" id="submit" value="注 册" class="am-btn am-btn-primary am-btn-sm am-fl">\n' +
' </div>\n' +
' </form>'
});
});
$('body').on('click', '#submit', function(){
var name = $("#name").val();
var username = $("#username").val();
var password = $("#password").val();
var phone = $("#phone").val();
var question = $("#question").val();
var answer = $("#answer").val();
$.ajax({
url: "/customer/register.do",
data: {
CustomerName:name,
CustomerLoginName: username,
CustomerPassword: password,
CustomerPhone:phone,
CustomerPwdQuestion:question,
CustomerPwdAnswer:answer
},
success: function(data) {
//注册成功
if(data.status === 0) {
layer.msg('注册成功!');//保存成功提示
} else {
layer.msg("用户名已存在");
}
layer.closeAll('iframe');//关闭弹窗
}
});
});
回答:
在url中增加‘http://’前缀,浏览器将会认为是个绝对url
默认不带'http://'则会认为是当前url
以上是 layer弹出层提交表单 的全部内容, 来源链接: utcz.com/p/175483.html