jquery - Partial View Update using Ajax refreshing the whole page -
I have a controlling mechanism that gives a partial view and I'm calling the controller verb method below from the main index view. .
Controller Public Partial Viewer GetEmployee {Entitle Valve} {var employee = db.getEmployeeById (val) back partial view ("_patiel employee employee", employee); } See index which makes partial calls @using (Html.BeginForm ()) {@ Html.AntiForgeryToken () @ Html.ValidationSummary ( True) & lt; Fieldset & gt; & Lt; Legend & gt; Get Employees & lt; / Legend & gt; & Lt; Div class = "editor-label" & gt; @ Html.LabelFor (model => model.Input) & lt; / Div & gt; & Lt; Div class = "editor-field" & gt; @ Html.EditorFor (model = & gt; model.Input) @ HTML.ValidationMessageFor (model => model.Input) & lt; / Div & gt; & Lt; P & gt; & Lt; Input ID = "GetEmp" type = "submit" value = "run" /> & Lt; / P & gt; & Lt; / Fieldset & gt; } & Lt; Div id = "employee results" & gt; & Lt; / Div & gt; And AJAX requests to my javascript as follows.
$ ('# GetEmp'). Click (function (e) {var empId = document getElementById ("GetEmp") .pk; $ .ajax ({url: '@ Url.Action ("GetEmployee", "Home"), type: "get ", // Method Method Data: {Val: empId}, cache: false, success: work (data) {$ (" # employee service "). Html (data); some do}, error: work Xhr) {Warning ("failed"); // to handle some error}}}}} In the above, whenever I enter the employee ID value in the text box and Submitting the form ... I partial view I want to attach the Div (result of the employee) element. I see partial results, but the whole page is refreshed, I submit the form and as a result I do not see partial view output.
Can someone tell me what I am doing and how can I show only a partial view without refreshing the whole page.
By submitting a form This causes the refresh, as long as you do not stop the default task:
$ ('# getEmp'). Click (function (e) {e.preventDefault ();
Public Partial Viewer GetEmployee {Entitle Valve} {var employee = db.getEmployeeById (val) back partial view ("_patiel employee employee", employee); } See index which makes partial calls @using (Html.BeginForm ()) {@ Html.AntiForgeryToken () @ Html.ValidationSummary ( True) & lt; Fieldset & gt; & Lt; Legend & gt; Get Employees & lt; / Legend & gt; & Lt; Div class = "editor-label" & gt; @ Html.LabelFor (model => model.Input) & lt; / Div & gt; & Lt; Div class = "editor-field" & gt; @ Html.EditorFor (model = & gt; model.Input) @ HTML.ValidationMessageFor (model => model.Input) & lt; / Div & gt; & Lt; P & gt; & Lt; Input ID = "GetEmp" type = "submit" value = "run" /> & Lt; / P & gt; & Lt; / Fieldset & gt; } & Lt; Div id = "employee results" & gt; & Lt; / Div & gt; And AJAX requests to my javascript as follows.
$ ('# GetEmp'). Click (function (e) {var empId = document getElementById ("GetEmp") .pk; $ .ajax ({url: '@ Url.Action ("GetEmployee", "Home"), type: "get ", // Method Method Data: {Val: empId}, cache: false, success: work (data) {$ (" # employee service "). Html (data); some do}, error: work Xhr) {Warning ("failed"); // to handle some error}}}}} In the above, whenever I enter the employee ID value in the text box and Submitting the form ... I partial view I want to attach the Div (result of the employee) element. I see partial results, but the whole page is refreshed, I submit the form and as a result I do not see partial view output.
Can someone tell me what I am doing and how can I show only a partial view without refreshing the whole page.
By submitting a form This causes the refresh, as long as you do not stop the default task:
$ ('# getEmp'). Click (function (e) {e.preventDefault ();
Comments
Post a Comment