I'm trying to execute the follow code below, from Run db query (sql server 2005) with ajax. Is it possible?.
<Head>
<script type="text/javascript">
function runAjax() {
$.ajax({
type: "POST",
url: "Index.aspx/PerformDatabaseQuery",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
alert("Test");
}
});
}
</script>
</Head>
I then have a button in the body which calls the function
<button type="button" onclick="runAjax();"/>
The code above resides in Home.cshtml
I'm not entirely sure if I created Index.aspx.cs correct, I clicked on a folder, add new class and simply named the file Index.aspx.cs. I put breakpoints in Index.aspx.cs and it's never hit. The callback function alert("Test") never triggers as well.
If I replace runAjax(); to execute
<script type="text/javascript">
function functionTwo() { alert('You clicked the bottom text'); }
</script>
The alert will display. May I ask where am I going wrong with this ajax call
F12key. Depending on the browser you'll either have a window popup or docked and in the there you'll have a tab which will sayConsoleclick on it and refresh your pageHome.cshtmlbe? Is it some latest update that allows one to use razor in asp.net?