Hi experts,
JQuery returns error: 'Error in loading...' But the controller works fine.
JQuery passes value to controller perfectly and the controller returns fine but there is still an error.
I don't know what's wrong with this.
Please help me!
Controller:
[HttpPost]
public ActionResult EditNews(string value)
{
long id = long.Pars(value);
News news = ....
return PartialView(news);
}
View:
@model MyProject.ViewModels.NewsViewModel
@Html.ListBoxFor(m => m.SelectedNews, Model.News,
new {id="newsListBox", size=10 ,data_url = Url.Action("EditNews", "News" ) })
And JQuery function:
$(function () {
$('#newsListBox').change(function () {
var selectedValue = $(this).val();
$.ajax({
url: $(this).data('url'),
dataType: 'text',
type: 'POST',
cache: false,
data: "value=" + selectedValue,
success: function (result) {
alert('It's fine');
},
error: function (result) {
alert('Error in loading...');
}
});
});
});