I'm extremely new to mvc and webtest so please bear wtih me here.
I have a customer view. The customer view calls a javascript function on document.ready
. This javascript call performs an ajax post to an action in the customer controller which returns json to the original javascript which in turn updates the customer view.
In my webtest, I have a request to the customer view, but the response is returned before the subsequent ajax call is completed and the view is updated so I don't have the latest page contents.
Is there a way to wait until that subsequent request is completed so I can analyze the full page with all the data? Or am I going about this in the wrong direction?
here is the view:
<script type="text/javascript" language="javascript">
//Set initial state of list during page load
$(document).ready(function() {
ApplyFilters();
})
</script>
Which calls this javascript:
function ApplyFilters() {
.....
$.ajax({
type: "POST",
url: "/Customer/FilterList",
datatype: "html",
beforeSend: function() {
//do some stuff
},
success: function(result) {
...
BindCustomrGrid($find(GridClientID), result);
},
error: function(req, status, error) {
// do some stuff
}
});
}
and finally the controller:
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult FilterList(string io, string name, string owner)
{
... // some api calls
return this.Json(new { customerList, serviceException });
}