Home  >  Article  >  Backend Development  >  $.get()老是执行不成功

$.get()老是执行不成功

WBOY
WBOYOriginal
2016-06-13 11:58:071213browse

$.get()总是执行不成功
 $(document).ready(function(){
                         $("#new").click(function(){
                          var order1=document.getElementById("new1").value;
                    
                          $.get("obj_search.php",{order:order1},function(response)
                     {
                      $("#show").html(response);
                     })
                     });
                 });
就是这一段,值总是传不过去,运行的时候根本就没有传值,我一直用这个方法写的都可以传,为什么这个总是运行不成功呢,我在$.get()之前加过alert(order1);可以运行就到了$.get()就不执行,

最近快被毕业设计弄疯,WEB开发懂得也不多,望大家赐教~~~~~~
------解决方案--------------------
alert(response);打印这个看看有结果集没
------解决方案--------------------
用jquery怎么不直接获取id
$("#new1").val();
顺便看一下你的ajax的URL是正确的么
------解决方案--------------------
$.get("obj_search.php",{order:order1},function(response)
------解决方案--------------------
用google浏览器查看http请求中都是啥,有没有返回你想要的东西,也可以直接访问obj_search.php?order=参数,看返回什么值。
------解决方案--------------------
用浏览器看下在点击的时候,是否有网络请求。

如果有的话,看下请求的地址是否错误,或者返回值是否异常

------解决方案--------------------
1、确认你的页面是从服务器上运行的
2、规范的写法是

$(document).ready(function(){<br />  $("#new").click(function(){<br />    var order1 = $("#new1").value;<br />    $.get("obj_search.php",{order:order1},function(response) {<br />      $("#show").html(response);<br />    })<br />  });<br />});

3、可在取得 order1 后 alert(order1) 观看一下
4、直接用浏览器运行 http://localhost/obj_search.php?order=1 
------解决方案--------------------
那你的 obj_search.php 是怎么写的?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php入门微了解Next article:对数组进展分组