weixin_33722405 2016-04-18 05:36 采纳率: 0%
浏览 28

将数据从$ .ajax发送到php

I am trying to send the username to php using ajax.

Here is my js.

$('#username').blur(function(){
    var username = $("#username").val();
    $.ajax({
        type: "POST",
        url: "dbquery.php",
        data: username,
        success: function(result){
            $("#dbdata").html(result);
        }
    });
});

And here is php.

$value = $_GET['username'];

I know it is about the ajax because everything worked fine when the ajax part was written in pure javascript.

  • 写回答

6条回答 默认 最新

  • elliott.david 2016-04-18 05:37
    关注

    Send data as an object as $_GET reads associative array of variables passed to the current script via the URL parameters

    data: {username:username},
    
    评论

报告相同问题?