d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Jquery Post Mvc 5
Add Reply New Topic New Poll
Member
Posts: 15,717
Joined: Aug 20 2007
Gold: 481.00
Apr 1 2014 12:43pm
having trouble getting my Controller in MVC to accept my jQuery post, apparently my script isn't getting the data correctly, it shows as data=undefined

Code
<script type="text/javascript">
$(function () {
$('#datepicker').datepick({ onSelect: postDate });
function postDate(date)
{
var currentDate = $("#datepicker").datepick("getDate");

$.ajax({
type: "post",
url: "SelectDay",
contenttype: "application/json; charset=utf-8",
data: currentDate
})
}
});
</script>


Code
// GET: /Timeclock/SelectDay
public ActionResult SelectDay(DateTime currentDate)
{
TimeclockViewModel tt = new TimeclockViewModel();
tt.currentDate = currentDate;
tt.Employee = User.Identity.Name;

return View(tt);
}]



error:

Quote
POST http://localhost:7398/Timeclock/SelectDay 500 (Internal Server Error) jquery-2.1.0.min.js:4
l.cors.a.crossDomain.send jquery-2.1.0.min.js:4
o.extend.ajax jquery-2.1.0.min.js:4
postDate Index:130
$.JQPlugin.createPlugin._updateInput jquery.datepick.js:1360
$.JQPlugin.createPlugin.selectDate jquery.datepick.js:1873
(anonymous function) jquery.datepick.js:1947
o.event.dispatch jquery-2.1.0.min.js:3
r.handle jquery-2.1.0.min.js:3


This post was edited by t9x on Apr 1 2014 12:47pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll