html页面ajax请求不执行

html-css013

html页面ajax请求不执行,第1张

我只能说说调试方法,具体看你怎么去执行调试。

1、在 $.post 之前随便加个 alert ,看 alert 有没有执行;如果执行,那就是 $.post 有问题,如果不执行,那说明 submit 事件就没有执行;

2、submit 内事件绑定,调试的时候加 event.preventDefault()防止表单提交后页面刷新或调走了。

$( "#target" ).submit(function( event ) {  

    alert( "Handler for .submit() called." )  

    event.preventDefault()

})

那是因为你res后面多了一个括号。

修改前:

$.get('t.php', '', function(res)){

修改后:

$.get('t.php', '', function(res){

建议学会使用F12,也就是浏览器调试。错误信息会很详细的,比如多了个括号或者少了个引号啥的,基本都能清楚的显示,一看便知,比直接肉眼查bug好多了。

<!doctype html>

<html>

<body>

<style>

.ipt180{width: 200pxheight: 50pxbackground: #cdcddcborder: none}

</style>

<input name="password" type="text" value="请输入密码" class="ipt180" id="workerpass" style='color:#666' onMouseOver ="this.style.backgroundColor='#879BD8'" onMouseOut ="this.style.backgroundColor='#f3f3f3'" onFocus="if(this.value==defaultValue) {this.value=''this.type='password'this.style.color='#000'}" onBlur="if(!value) {value='请输入密码' this.type='text'this.style.color='#666'}">

</body>

</html>

可以执行呀,我完全拷贝你的代码,就给input加了个样式,还有你的最后一句代码的style写错了....因为name="password" 所以是黑点~