I made this web service that returns a datatable from sql server db. Can someone help me with the jquery to display it?
web service
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebService : System.Web.Services.WebService
{
DataTable dt = new DataTable();
[WebMethod]
public DataTable dbAccess()
{
using (SqlConnection conn = new SqlConnection(
ConfigurationManager.ConnectionStrings["localConnectionString"]
.ConnectionString))
{
using (SqlDataAdapter da = new SqlDataAdapter())
{
conn.Open();
da.SelectCommand =
new SqlCommand("SELECT VehicleMake FROM VehicleMakes", conn);
da.Fill(dt);
}
conn.Close();
}
return dt;
}
}
and this is as far as I got with the jquery
<script type="text/javascript">
$(function () {
$('#Button1').click(getData);
});
function getData() {
$.ajax({
type: "POST",
url: "WebService.asmx/dbAccess",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
// What goes here?
},
failure: function (msg) {
//error message
}
});
}
</script>