使用jQuery是非常简单的,假设您要发布的URL位于同一台服务器上,或已实现CORS
$(function() {
$("#employeeLink").on("click",function(e) {
e.preventDefault(); // cancel the link itself
$.post(this.href,function(data) {
$("#someContainer").html(data);
});
});
});
如果您坚持使用我强烈劝阻的框架,请填写表单并提交链接
并使用(在纯JS中)
window.οnlοad=function() {
document.getElementById("employeeLink").οnclick=function() {
document.getElementById("myForm").submit();
return false; // cancel the actual link
}
}
没有形式我们需要做一个
window.οnlοad=function() {
document.getElementById("employeeLink").οnclick=function() {
var myForm = document.createElement("form");
myForm.action=this.href;// the href of the link
myForm.target="myFrame";
myForm.method="POST";
myForm.submit();
return false; // cancel the actual link
}
}