AJAX gives 400 bad request error

the post request returns a 400 bad request error however if i test it on rest client it gives 200..

below is ajax call

url is

var ajaxUrl = "/json/accounts/tallySales";
var endDate = $('#dateRangeEnd').val();
var startDate = $('#dateRangeStart').val();




$.ajax({
    url: ajaxUrl,
    type: "POST",
    data: JSON.stringify(jsonData),
    contentType: "application/json",
    dataType: 'json',
    success: function(data) {
        if ((data.tallySales !== undefined) && (data.tallySales.length > 0)) {
            populateJqgrid(data.tallySales, data.totalRecords);
        } else {
            $("#searchResultGrid").jqGrid("clearGridData");

            smoke.alert(data.message);
            //smoke.alert("No data found for current search paramters");
        }
        $(".doSearch").each(function() {
            $(this).html($(this).val());
        });
        $(".doSearch").removeAttr("disabled");
    },
    error: function() {
        $(".doSearch").each(function() {
            $(this).html($(this).val());
        });
        $(".doSearch").removeAttr("disabled");
    }
});


Source: ajax

Leave a Reply