i need to call the controller action from javascript on imag dragging.
my javascript code is
$trash.droppable({
accept: \"#gallery > img\",
// activeClass: \"ui-state-highlight\",
drop: function (event, ui) {
var a = ui.draggable;
var itemsarray = [];
itemsarray.push(a[0].id);
// $.getJSON(\'@Url.Action(\"SaveImage\")\', { imageids: itemsarray }, function (mydata) {
// alert(mydata);
// });
$.ajax({
url: \'@Url.Action(\"SaveImage\")\',
data: JSON.stringify({ imageids: 1 }),
contentType: \'application/json\',
dataType: \'json\',
type: \'POST\',
success: function (mydata) {
alert(mydata);
}
});
deleteImage(ui.draggable);
}
});
In my controller code is,
[HttpPost]
public ActionResult SaveImage(int imageids)
{
GalleryService galService = new GalleryService();
//galService.UpdatePublishedImages(imageids);
// return View(\"Index\");
return Json(\"test\",JsonRequestBehavior.AllowGet);
}
and my view is
@using (Html.BeginForm(\"UploadImage\", \"Gallery\", FormMethod.Post, new { enctype = \"multipart/form-data\" }))
{
<div class=\"uploadMiddlePanel \">
<p class=\"title\">
<img src=\"Images/event_equation_icon.png\" width=\"25\" height=\"25\" alt=\"event Logo\" />
Gallery Management</p>
<p class=\"lightGrayTitle\">
Upload Images</p>
<div class=\"UploadContainer\">
<div class=\"uploadImagePanel\" id=\"gallery\">
@foreach (var src in @imageList)
{
<img src=\"@Url.Content(\"~/Content/GalleryImages/\" + src.Text)\" id=\"@Url.Content(src.Value)\" alt=\"Image\" class=\"imagePreview\" />
}
but my js calling function didnt fore my controller, is am missing anything or is any other way to call controller from js.
thanks





Rating:
The post javascript – mvc controller didnt fire from js appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/javascript-mvc-controller-didnt-fire-from-js.html
No comments:
Post a Comment