Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

pass input from HTML page to web api

$
0
0

hello all,

i have two projects, one is pure web api, there i have my controlls and models, the same api is published in IIS. below is my sample api code to insert data

second project has only html pages(UI Project). from html page using jquery i have collected input, now i have to send them into API published in IIS here, my doubts are

Is is possible to send input to my API from HTML page itself using jQuery? if yes may i know 

my web api seems below

// POST: api/Employees
[ResponseType(typeof(tblEmployee))]
[Route("api/PosttblEmployee")]
public IHttpActionResult PosttblEmployee(tblEmployee tblEmployee)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}

db.tblEmployees.Add(tblEmployee);
db.SaveChanges();

return CreatedAtRoute("DefaultApi", new { id = tblEmployee.employeeId }, tblEmployee);
}


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>