普通网友 2013-03-01 09:45
浏览 15

来自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?

  • 写回答

4条回答 默认 最新

  • weixin_33695450 2013-03-01 09:46
    关注

    instead of returning, call

    use

    if(isset($_POST['search']))
    {
        echo 'yes';
    }
    else
    {
        echo 'no';
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题