来自PHP文件的Ajax响应

I'm being a bit of an idiot and seem to be unable to find an answer to my question, I am wanting to send a search request to my PHP file and return results, when I do that I can't seem to do the right thing, I'm definitely using the correct file but I'm not sure how to return results from the PHP file (I'm fairly new to ajax this so I do apologies for sound silly)

Jquery/Ajax:

    $('#searchGo').click(function() {
        var tempVar = 0;
        var request = $.ajax({
            async: false,
            url: "/../commerce/search.php",
            type: "POST",
            data: "search=" + $('#search').val(),
            dataType: "html"
        });
        alert(request.responseText + ' test');
    });

Search.php:

if(isset($_POST['search'])) {
    return 'yes';
}
return 'no';

And the response text isn't giving me anything, am I doing something wrong?

查看全部
weixin_33729196
weixin_33729196
2013/03/01 09:45
  • php
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

4个回复