Hi all i am working on webapi now here i need to update data right i am having table (entitymodel)
id | value
1 | previous data
2 | new data
now i need to update the table means iam updating ckeditor data iam some text into ckeditor and once mouseleves the ckeditor div i need to save that data into db so everything is fing when iam get moving to controllers i got controllers empty form ajax call could u plz help me
here my ajaxcall:
<script type="text/javascript">
$(document).ready(function () {
var editor = CKEDITOR.editor.replace('editor1');
$('#btndiv').mouseleave(function (event) {
$('#btndiv1').hide("slow");
alert(1);
var value = editor.getData();
$('#btndiv').append(value);
// send your ajax request with value
var dataToPost = JSON.stringify(value);
alert('hi');
alert(dataToPost+"got data");
$.ajax({
type: "Put",
url: "/api/UpdateCkeditor",
contentType: "application/json; charset=utf-8",
data: dataToPost,
dataType: "json",
success: function () {
// do what you want on success.
}
});
});
});
</script>
here iam having data (value) od when it moves to controllers it shows empty
here my controllers:
public void Put(ckeditormodels value)
{
webapiEntities db = new webapiEntities();
var empObj = db.ckeditorDatas.First(c => c.value ==value.value);
empObj.value = value.value;
db.SaveChanges();
}
here my models:
public class ckeditormodels
{
public int id { get; set; }
public string value { get; set; }
}
even it showing error and in controolers showing some error like object reference not se to an object of instance plz help me to do this work thanks in advance