Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
}
});
}
Posted
Updated 31-May-17 23:21pm

1 solution

Check in debugger mode to know in which line the issue is and check the controller action method name and parameter are same as the Ajax (URL and param)
 
Share this answer
 
Comments
Jaydeep Shah 1-Jun-17 5:05am    
when i put all code on document.ready then it works properly ..
so can i every time put all code on document.ready function ??!!
Ramesh Kumar Barik 1-Jun-17 5:22am    
If you create a separate function then no need to put in side Ready function. But if we create events(Click/Change events etc) then it needs to put those events in Ready function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900