Daniel Orlan Daniel Orlan - 1 year ago 141
Ajax Question

ASP.NET Ajax doesnt call Url

Ajax doesnt seem to be working on my View. I simplified my problem down to having a button call a controller method via ajax. The result is the same html of the view is being appended to the div. Looking through the debugger, the same GetEventForm url is called and not TestAjax

Button in GetEventForm.cshtml

<input type="button" id="btn" value="Test Ajax" class="btn-sm"/>

<div id="rule"> </div>


<script type="text/javascript">
$(document).ready(function () {
$('#btn').on('click', function() {
type: 'GET',
cache: false,
Url: '@Url.Action("TestAjax","Events")',
success: function(result) { $("#rule").html(result); }


public string TestAjax()
return "Response string from Controller!";

Before Click

After Click

Answer Source

Try lowercase "url":


    url : '...'

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download