asp.net - Load Partial View based on Autocomplete Selection -


i'm learning asp.net, mvc, , jscript first time. i'm attempting use selection autocomplete ajax call data , load partial view data. controller gets request selected id, partial view never loads. doing wrong?

(the view , partial view have different models - didn't think issue)

controller

    public actionresult getemployee(int id)     {         humanresourcesmanager man = new humanresourcesmanager();         var emp = man.getemployee(id);         return partialview("_employeedetails", emp);     } 

view

@model humanresources.web.models.employeemodel <p>       selected employee: @html.textbox("employeesearch") </p> <script type="text/javascript">     $("#employeesearch").autocomplete({         source: function (request, response) {                 $.ajax({                 url: "@(url.action("findemployee", "employee"))",                     type: "post",                     datatype: "json",                     data: { term: request.term },                     success: function (data) {                         response($.map(data, function (item) {                         return { label: item.displayname, value: item.displayname, id: item.id };                         }))                     }                 })         },         select: function (event, ui) {             if (ui.item) {                 getemployeedetails(ui.item.id);             }         }     });       function getemployeedetails(id) {      $.ajax({         url: '/employee/getemployee',         type: 'post',         async: false,         data: { id: id },         success: function (result) {             $("#partialview").html(result);         }     });     }      </script>      <div id="#partialview">         @*partial view test*@     </div> 

partial view

@model humanresources.objects.employee.employeeinformation @{      layout = null; }  <h1>this test</h1> 

remove # partial view div id. add when you're using jquery's id selector.

<div id="partialview">     @*partial view test*@ </div> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -