jquery的ajax用get步骤无法将值传到后台,why?

WBOY
Release: 2016-06-13 12:51:30
Original
809 people have browsed it

jquery的ajax用get方法无法将值传到后台,why??????
如题:
//以下是js的方法
function login() {
$.ajax({
     type: "get",
     url:'valid.php', 
     data:"username=admin", 
     dataType:"json", 
     success:ajaxComplete(result), 
     error:ajaxError(response)});
   });
}

//以下是valid.php
echo $_GET['username'];
?>

触发login()方法后,页面报错 Notice: Undefined index: username,意思是找不到这个参数,这是为什么呢,求解!!

jquery ajax
------解决方案--------------------
你连 js 都写错了,怎么可以得到结果?
function login() {<br />
  $.ajax({<br />
    type: "get",<br />
    url:'valid.php', <br />
    data:"username=admin", <br />
    dataType:"json", <br />
    success:ajaxComplete, <br />
    error:ajaxError<br />
  });<br />
}<br />
Copy after login

success 和 error 需要的都是回调函数
你要么赋予函数名,要么直接定义匿名函数
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!