i had done crud operation using mvc.
i share my jquery code here
some timg on list metod onclik not work
i mean
'
Edit' +
i create function Editme() but it not call.
What I have tried:
var room_id = '';
$(document).ready(function () {
listdata();
$("#dialog").dialog({
modal: true,
autoOpen: false,
title: "CRUD",
width: 500,
height: 500
});
$("#btnShow").click(function () {
room_id = '';
$('#dialog').dialog('open');
});
$("#btnsave").click(function (roomtype) {
$.ajax({
url: '/Crud/Create',
type: 'POST',
data: {
roomtype: $("#txtroomtype").val(),
id: room_id
},
success: function (result) {
listdata();
},
error: function () {
}
});
});
$("#create-user").button().on("click", function () {
$('#dialog').dialog('open');
});
});
//list data
function listdata() {
$.ajax({
url: '/Crud/List',
type: 'POST',
success: function (result) {
$("#data").empty();
$.each(result.data, function (Index, item) {
$("#data").append(' ' +
' ' + item.id + '' +
' ' + item.roomtype + '' +
'
Delete' +
'
Edit' +
' ');
});
},
error: function () {
alert("error");
}
});
};
function Delelemee(id) {
$.ajax({
url: '/Crud/Delete',
type: 'POST',
data : {
id: id,
},
success: function () {
alert("DELETE SUCCESSFULLLY..");
listdata();
},
error: function () {
alert("data not delete");
}
});
};
function Editme(id)
{
room_id = id;
$.ajax({
url: '/Crud/getuserbyid',
type: 'POST',
data: {
id: id,
},
success: function (result) {
console.log(result);
$("#txtroomtype").val(result.data.roomtype);
$('#dialog').dialog('open');
},
error: function (err) {
alert(err);
}
});
}