Sto provando a inviare una chiamata utilizzando ajax ma in Chrome è in aumento errore ma in Firefox non c'è errore. Ma ancora non può chiamare il metodo. Ho provato a registrare la mia chiamata in firebug ma non c'è richiesta di chiamata in firebug. Quindi questa è la ragione per cui non c'è errore in firefox.Impossibile caricare la risorsa: il server ha risposto con uno stato di 500 (Errore interno del server) nella funzione Bind
Index.chshtml codice è al di sotto
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);
}
});
});
});
});
}
metodo controller
public JsonResult SaveColumnInfo(string columnIndex, string value)
{
CookieHelper helper=new CookieHelper();
helper.UpdateCookie(int.Parse(columnIndex), value.ToString());
return Json("Success");
}
Errore in cromo
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
Stai facendo un post. Hai contrassegnato SaveColumnInfo come HttpPost? – Fals
Sì, ho provato con HttpPost ma non ho avuto successo. In altre pagine dell'applicazione mu sto usando lo stesso metodo di chiamata ajax senza attributo HttpPost e funziona anche se va bene. – Haris
Non lo penso, ../../GlobalSearch/SaveColumnInfo è sbagliato! Non puoi digitare questo tipo di URL!/GlobalSearch/SaveColumnInfo dovrebbe funzionare! – Fals