I have the following HTML code:
<div id="main"> <form Id="search-form" action="/ViewRecord/AllRecord" method="post"> <div> <fieldset> <legend>Search</legend> <p> <label for="username">Staff name</label> <input id="username" name="username" type="text" value="" /> <label for="softype"> software type</label> <input type="submit" value="Search" /> </p> </fieldset> </div> </form> </div>
And the following Javascript code (with jQuery as a library):
$(function() { $("#username").click(function() { $.getJSON("ViewRecord/GetSoftwareChoice", {}, function(data) {
Now, how to check $("#username").click so that for a given input it
- calls the correct URL (in this case its
ViewRecord/GetSoftwareChoice ) - And is an output expected (in this case
function(data) )?
Any idea how to do this with QUnit ?
Edit: I read QUnit Examples , but they seem to be dealing with a simple script without AJAX interaction. And although there are ASP.NET MVC examples , but I think they really test the server output for an AJAX call, i.e. It is still checking the server response, not the AJAX response. I want to test the response on the client side.
source share