I am currently trying to create an upload control with progress bar in MVC using jquery. I keep running into a problem however in that mvc doesn\'t work in parallel threads?
You will lose your view state if you call an action that returns a View. You can pass data between actions using the TempData if you like, but that probably won't solve your problem. Sounds to me like what you want here is an action that will return a JSON element that you can call with some asynchronous javascript.
For your action you would have:
public ActionResult GetSuggestions(string searchText)
{
return Json(new { SearchText = searchText + "completestring"});
}
And then on your form you have some asynchronous javascript using jQuery:
function startAutoComplete() {
var searchText = $("#inputText").val();
$.getJSON("/Search/GetSuggestions?searchText=" + searchText, null, autoCompleteResponse);
}
function autoCompleteResponse(data) {
if (data.SearchText) {
$("#inputText").val(data.SearchText);
$("#inputText").select();
}
}
This will allow you to get some information from your server without posting the form and keeping the viewstate of the client in tact.
There is a full write up of the example here that might help.