I have an ASP.NET MVC web application consisting of one View page, where a user is asked to type into two textboxes 2 different flavors of ice cream. Then on blur (when the cursor moves away from both text boxes), then the $.get
method is invoked. The IsFavoriteIceCreamCombo
method returns true if the 2 ice cream flavors that the user entered in the text box are my favorite combo.
[Note that the onblur logic is not shown here for brevity]
Here are a few snippets of the JavaScript code:
var iceCream1 = document.getElementById('#ice-cream-1');
var iceCream2 = document.getElementById('#ice-cream-2');
....
var result = $.get('@Url.Action("IsFavoriteIceCreamCombo", "IceCream")?option1=' + iceCream1.value + ';option2=' + iceCream2.value);
alert(result);
And here is the Action method in the IceCreamController
:
[WebMethod]
public bool IsFavoriteIceCreamCombo(string option1, string option2)
{
if (...)
{
return true;
}
return false;
}
How can I get alert(result)
to alert the bool return value from the function?