$("#submit").bind('click',function(){
$.ajax({
type: "post",
url: "<%=_c%>+/certBind/certbinding/binding.action",
data: "text",
success: function(msg){
if(msg=="success"){
alert("提交成功!");
}else {
alert("error!");
}
}
});
});
为什么这样写不能正常发送请求呢?我希望向服务端发送text文本
jquery
------解决方案--------------------
url: "<%=_c%>+/certBind/certbinding/binding.action",这里多了个"+",如果要用"+"来连接,这样写: url: <%=_c%>+"/certBind/certbinding/binding.action"试试
------解决方案--------------------
$("#submit").bind('click', function () {
$.ajax({
type: "post",
url: "<%=_c%>+/certBind/certbinding/binding.action",
data: "text",
success: function (msg) {
if (msg == "success") {
alert("提交成功!");
} else {
alert("error!");
}
}
});
return false;//阻止表单提交,感觉你的这个submit按钮是type="submit",这样会提交表单导致ajax不执行
});