Reputation: 655
I've this scenario:
Site.Master
...
<%= Html.TextBox("ricerca") %>
<img src="" alt ="" id="search" />
...
<script type="text/javascript">
$(function() {
$('#search').click(function() {
var valueSearch = $('#ricerca').val();
Search(valueSearch);
});
});
function Search(valueSearch) {
$.ajax({
type: "POST",
url: "/Home/Search",
data: "value=" + valueSearch
});
}
HomeController
[HttpPost]
public ActionResult Search(string value)
{
//...logic search
return View();
}
When i click on image called correctly the Search action, but after "Return View();" don't load the Search view (positioned in the folder Home)
Why don't show?
Upvotes: 1
Views: 2238
Reputation: 342635
At no point are you inserting the data returned from the server into the document. That needs to happen within $.ajax
's success callback:
$.ajax({
type: "POST",
url: "/Home/Search",
data: "value=" + valueSearch,
success: function(data) {
alert(data);
$("#someDiv").html(data);
}
});
Upvotes: 1