Pass datetime to controller action with jquery-ajax -
Pass datetime to controller action with jquery-ajax -
how pass datetime using jquery ajax controller action? using jquery ui datepicker ie.textbox , calendar control.
the action still controller/action/11/12/2011 doesn't work...any help please?
this have:
$.ajax({ url: '<%: url.action("mypartial", "mycontroller") %>/' + datestring, type: "get", datatypestring: "html", success: function (response, status, xhr) { var container = $("#mycontainer"); container.html(response); }, error: function (xmlhttprequest, textstatus, errorthrown) { var container = $("#mycontainer"); container.html('<div class="error">an error occurred</div>'); } });
where var datestring = $('#mydate').val();
if have action method on controller this:
[httpget] public actionresult somemethod(int objectid, datetime startdate, datetime enddate) { ... }
you can utilize next construction in javascript:
var start = new date(); var end = new date(); end.setdate(start.getdate() - 1); var parameters = { objectid: objid, startdate: start.toutcstring(), enddate: end.toutcstring() }; // .... $.ajax({ url: '/yourcontroller/somemethod', method: 'get', data: parameters, cache: false, success: function (data, textstatus, jqxhr) { //... }, error: function (jqxhr, textstatus, errorthrown) { //... } });
it piece of code example. not exact solution, can utilize illustration modification.
ajax datetime jquery datepicker
Comments
Post a Comment