Failed to load resource: the server responded with a status of 500 (Internal Server Error) in Bind function

Haris picture Haris · Oct 4, 2013 · Viewed 517.8k times · Source

I'm trying to send a call using ajax but in Chrome it is rising error but in firefox there is no error. But still it can't calling the method. I tried to record my call in firebug but there is no call request in firebug. So that's the reason there is no error in firefox.

Index.chshtml code is below

function onLoad(e) {

    var grid = $(this).data("tGrid");
    //bind to the context menu of the Grid's header
    event.preventDefault();
    $(this).find(".t-grid-header").bind('contextmenu', function (e) {
        //wait for the menu to be generated
        setTimeout(function () {
            // bind to the checkboxes change event. The context menu has ID in the format "GridName" + "_contextmenu"
            $('#globalsearchgrid_contextMenu :checkbox').change(function () {
                debugger;
                var $checkbox = $(this);
                // the checked state will determine if the column has been shown or hidden
                var checked = $(this).is(":checked");
                // get the index and the corresponding column from the Grid's column collection
                var columnIndex = $(this).data("field");

                var request = "{'columnIndex':'" + columnIndex + "'value':'" + checked + "'}";
                $.ajax({
                    type: "POST",
                    url: "../../GlobalSearch/SaveColumnInfo",
                    data: request,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) { },
                    error: function (xhr, status, error) {
                        alert(error.responseTextss);
                    }

                });
            });
        });
    });
}

Controller method

 public JsonResult SaveColumnInfo(string columnIndex, string value)
    {
        CookieHelper helper=new CookieHelper();
        helper.UpdateCookie(int.Parse(columnIndex), value.ToString());

        return Json("Success");
    }

Error in chrome

    POST http://localhost:3577/GlobalSearch/SaveColumnInfo 500 (Internal Server Error) 
    jQuery.ajaxTransport.send 
    jQuery.extend.ajax 
    (anonymous function) 
    jQuery.event.handle 
    jQuery.event.add.elemData.handle.eventHandle

Answer

asantaballa picture asantaballa · Oct 4, 2013

The 500 code would normally indicate an error on the server, not anything with your code. Some thoughts

  • Talk to the server developer for more info. You can't get more info directly.
  • Verify your arguments into the call (values). Look for anything you might think could cause a problem for the server process. The process should not die and should return you a better code, but bugs happen there also.
  • Could be intermittent, like if the server database goes down. May be worth trying at another time.