doubi1931 2010-08-27 14:02
浏览 55
已采纳

Jquery AJAX响应不起作用

For some reason this jQuery function is not working properly. Here's my code... the response div is not updating with my response.

WHEN AJAX FUNCTION IS CALLED

if ($action == 'sort') {

    echo 'getting a response';
    return 0;

}

JQuery FUNCTION

function sort() {

    $.ajax({
        type: "POST",
        url: "contributor_panel.php?action=sort",
        data:"sort_by=" + document.getElementById("sort_by").value +
             "&view_batch=" + document.getElementById("view_batch").value,
        success: function(html){

            $("#ajaxPhotographSortResponse").html(html);

        }
    });

}

DIV TO REPLACE

<div id="ajaxPhotographSortResponse"></div>
  • 写回答

2条回答 默认 最新

  • douwen2158 2010-08-27 14:20
    关注

    Move the action=sort into the data property of the $.ajax function. You're making a POST request, but appending data onto your query string like a GET request. Data only appends to the query string if it's a GET request.

    Example:

    $.ajax({
            type: "POST",
            url: "contributor_panel.php",
            data: {action:'sort', sort_by: $('#sort_by').val(), view_batch: $('#view_batch').val()},
            success: function(html){
    
                $("#ajaxPhotographSortResponse").html(html);
    
            }
        });
    

    http://api.jquery.com/jQuery.ajax/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流