douke9379 2015-08-17 09:40
浏览 140

ajax jquery返回整个页面

this question has been asked before but the answers seem not to work on me. My Ajax returns the whole page when i perform a autocomplete search

ajax to search from database

$(function(){ $(".search_keyword").keyup(function() { 
var search_keyword_value = $(this).val();
var dataString = 'search_keyword='+ search_keyword_value;
if(search_keyword_value!='')
{
    $.ajax({
        type: "POST",
        url: "/ajax/search.php",
        data: dataString,
        cache: false,
        success: function(html)
            {
                $("#result").html(html).show();
            }
    });
} else{
    document.getElementById('result').innerHTML ='';
}
return false;    });

html page

<form method="get" action="/?page=results" class="navbar-form" autocomplete="off">
        <input type="text" name="query" class="search_keyword"/>
        <button type="submit" nam>Search</button>
    </form>
    <div id="result"></div>

would really appreciate the help Guys

  • 写回答

2条回答

  • donglian7879 2015-08-17 09:48
    关注

    check whether the page you are calling correct path or not...

    due to 404 error only, it will returns whole page. may be the ajax url not found

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站