1
Answer

i need to pass whole model from view to controler using ajax

erum mirza

erum mirza

7y
137
1
can any one help me how to pass model object from view to controller using ajax .i have below code but not working.i am getting null in EmpAddType .even i selected any thing from drop downlist
 
  1. <script>  
  2.   
  3.     function GetFilter() {  
  4.   
  5.         var employeeAddress = {  
  6.             "EmpAddType": $("#drop1 option:selected").text()  
  7.   
  8.   
  9.         }  
  10.   
  11.          
  12.         alert($("#drop1 option:selected").text());  
  13.         alert(employeeAddress.EmpAddType);  
  14.   
  15.   
  16.           
  17.   
  18.         $.ajax({  
  19.             url: '@Url.Action("SaveAddress")',  
  20.             type: 'POST',  
  21.             cache: false,  
  22.             contentType: 'application/json',  
  23.             dataType: "json",  
  24.   
  25.             data: JSON.stringify(employeeAddress),  
  26.             success: function (data) {  
  27.                 alert("You Multiple Data Passed Successfully");  
  28.             },  
  29.               
  30.             error: function () {  
  31.                 alert("failed");  
  32.             }  
  33.         });  
  34.   
  35.   
  36.   
  37.     }  
  38.     function showDiv() {  
  39.   
  40.         $('#MailingContactDetails').show(1000)  
  41.     }  
  42.     function showDiv2() {  
  43.   
  44.         $('#AccountDetail').show(1000)  
  45.     }  
  46.   
  47. </script> 

 

Answers (1)