SHARE
TWEET

Untitled

a guest Oct 12th, 2017 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [HttpPost]
  2.     public myData test(myData m)
  3.     {
  4.         return m;
  5.     }
  6.    
  7. public class myData
  8. {
  9.     public int Id { get; set; }
  10.     public string Name { get; set; }
  11. }
  12.    
  13. <html>
  14.  
  15. <head>
  16.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  17. </head>
  18.  
  19. <body>
  20.     <script>
  21.         var model = {
  22.             Name: "Shyju",
  23.             Id: 123
  24.         };
  25.  
  26.         $.ajax({
  27.             type: "POST",
  28.             data: model,
  29.             url: "http://localhost:52884/api/contact",
  30.         }).done(function(res) {      
  31.             console.debug(res);
  32.             // Do something with the result :)
  33.         });
  34.     </script>
  35. </body>
  36.  
  37. </html>
  38.    
  39. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:52884/api/contact. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
RAW Paste Data
Top