我是WordPress的新手。我有一个这样的jQuery代码。。。在我的header.php
文件
jQuery(document).ready(function(){
jQuery("#wp-submit").click(function(){
username=jQuery("#userName").val();
password=jQuery("#passWord").val();
jQuery.ajax({
type: "POST",
url: "<?php echo "http://" . $_SERVER[\'HTTP_HOST\'] . $_SERVER[\'REQUEST_URI\']; ?>",
data: "name="+username+"&pwd="+password,
success: function(html){
if(html==\'true\') {
jQuery("div#result").css(\'display\', \'inline\', \'important\');
jQuery("div#result").html("Login Successful");
console.log(\'true\');
}
else{
jQuery("div#result").css(\'display\', \'inline\', \'important\');
jQuery("div#result").html("Wrong username or password");
}
} });
return false;
});
});
下面是同一个文件(header.php)中的php代码: <?php
$uName = $_POST[\'name\'];
$pWord = md5($_POST[\'pwd\']);
$results= $wpdb->get_results("select * from wp_users where user_email=\'".$uName."\' and user_pass=\'".$pWord."\'");
if(count($results)==1)
{
echo \'true\';
}
else {
echo \'false\';
}
我无法向服务器发送请求,我遇到了404错误。我做错了什么?