Note that there are some explanatory texts on larger screens.

plurals
  1. POPass jquery parameters to Controller Action
    primarykey
    data
    text
    <p>I want to pass 2 parameters with ajax function to the Controller Action, but the code that I use it's not working. The action is called but without parameters; what is wrong in the code below? Please help. Thank you!</p> <p>view code:</p> <pre><code> &lt;fieldset&gt; @Html.Label("Start date: *") @Html.TextBoxFor(model =&gt; model.startDate, new { Class = "calendar", data_mini = true, data_role = "datebox", data_options = "{\"mode\":\"calbox\",\"useNewStyle\": true,\"overrideStyleClass\": \"calendar\",\"fieldsOrderOverride\": [\"d\",\"m\",\"y\"],\"headerFormat\":\"%A,%d, %-m, %Y\",\"dateFormat\":\"DD-MM-YYYY\",\"useTodayButton\":true}" }) &lt;/fieldset&gt; &lt;fieldset&gt; @Html.Label("End date: *") @Html.TextBoxFor(model =&gt; model.endDate, new { Class = "calendar", data_mini = true, data_role = "datebox", data_options = "{\"mode\":\"calbox\",\"useNewStyle\": true,\"overrideStyleClass\": \"calendar\",\"fieldsOrderOverride\": [\"d\",\"m\",\"y\"],\"headerFormat\":\"%A,%d, %-m, %Y\",\"dateFormat\":\"DD-MM-YYYY\",\"useTodayButton\":true}" }) &lt;/fieldset&gt; &lt;fieldset&gt; @Html.Label("Submited: *") &lt;/fieldset&gt; &lt;a data-role="button" id="search" name="search" data-theme="a" class="book ui-btn ui-btn-corner-all ui-shadow ui-btn-up-a"&gt; &lt;span class="ui-btn-inner ui-btn-corner-all"&gt;&lt;span class="ui-btn-text"&gt;Search&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; </code></pre> <p>Jquery code:</p> <pre><code>&lt;script type="text/javascript"&gt; $("#search").click(function () { GetNewDaysList(); }); //gets elements for the selected dates function GetNewDaysList() { var action = '@Url.Action("GetNewDays", "ApproveWork")'; var criteria = new Array($("#startDate").val(),$("#endDate").val()); var opt = { type: "GET", data: { criteria: criteria }, url: action, success: DaysListSuccess, error:DaysListFailed }; jQuery.ajax(opt); } function DaysListSuccess(data) { if (data != undefined) { $.mobile.hidePageLoadingMsg(); $('ul').hide(); $("#employeeDays").html(data).trigger('create'); $("#searchSection").show(); $("#employeeDays").show(); } } function DaysListFailed() { // } }); </code></pre> <p></p> <p>Controller code:</p> <pre><code> [HttpGet] public ActionResult GetNewDays(IEnumerable&lt;string&gt; criteria) { List&lt;string&gt; criteriaList = criteria.ToList(); DateTime start = DateTime.ParseExact(criteriaList[1],"dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture); string startToString = start.ToString("yyyyMMdd"); DateTime end = DateTime.ParseExact(criteriaList[2], "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture); string endToString = end.ToString("yyyyMMdd"); List&lt;string&gt; daysList = new List&lt;string&gt;(); var model = new ApproveWorkModel(); model.daysList = daysList; return PartialView ( "EmployeeDays",model); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload