Asc.net에서 X-Editable Plugin을 jquery Datatables과 함께 사용하면 내 테이블을 편집 할 수 있습니다. jQuery $ .ajax() 메서드를 사용하여 컨트롤러에서 메서드를 호출하지만이 함수를 호출 할 때 해당 메서드를 누르지 않습니다. 누구나 jQuery $ .ajax() 메서드를 사용하는 방법을 알고 계십니까?asp.net MVC4와 함께 Ajax를 사용하는 방법
$('#example').dataTable();
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td', nRow).wrapInner('<a class="xediable-example" href="#"></a>').editable({
type: 'text',
pk: 1,
name: 'test',
url: function (params) {
var urlj = "TestMethod"
return $.ajax({
type: 'POST',
url: urlj,
data: JSON.stringify(params),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false,
cache: false,
timeout: 10000,
});
}
});
return nRow;
}
});
제어 방식 :
public static string TestMethod(string name, string pk, string value)
{
return "" ;
}
오류 메시지 :
Erreur du serveur dans l'application '/'.La ressource est introuvable. Description : HTTP 404. La ressource recherchée (ou l'une de ses dépendances) a peut-être été supprimée ou renommée ou bien elle n'est plus disponible temporairement. Vérifiez l'URL ci-après et assurez-vous qu'elle est correcte. URL demandée: /H41_TitreConge/TestMethod Informations sur la version : Version Microsoft .NET Framework :4.0.30319; Version ASP.NET :4.0.30319.17929
'TestMethod'는 컨트롤러 액션이 될 필요가있다. –
@Chris에 동의합니다. 귀하의 TestMethod() 정적, 그것도 정적 클래스에있는 것을 의미합니다. 하지만 ASP.NET MVC는 정적 컨트롤러 나 동작을 허용하지 않기 때문에 TestMethod()가 MVC에 의해 호출 될 수 없습니다 - [왜 그렇게되었는지 설명] (http://stackoverflow.com/a/6127153/815960) – kasitan