In this article, I will show you how to send a post with to the server from jQuery ui Slider using jQuery Ajax . The jQuery ui Slide allows the user to select certain numeric value range from it. The Slide(event,ui) will be triggered on every mouse move on a slider. We must register three external links.
Asp.net mvc jQuery ajax mvc4 example:
JS Code:
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<link href=https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css
rel="stylesheet">
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".slider").slider({
range: "max",
min: 0.2,
max: 5,
stop: function (event, ui) {
var rangevalue= $("#slider1").slider("value");
$.ajax({
url: '@Url.Action("AdjustRange", "Home", new { area = "" })',
type: 'POST',
data: {
Rvalue: rangevalue,
},
success: function (data) {
},
error: function (data) { }
});
}
});
});
</script>
Server Side: Controller
The jQuery Ajax request the controller action method, there we can do our operations and return json result.
[HttpPost]
public virtual ActionResult AdjustImage(short Rvalue)
{
//Do operation here
return Json(new { message = “success” }, JsonRequestBehavior.AllowGet);
}
JQuery ui Slider functionalities:
max: maximum value of slider
min: minimum value of slider
range: It may either “max” or “min”
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article