brothers28 brothers28 - 3 months ago 6
jQuery Question

Data won't be load in div

I have a problem in one of my ASP.NET MVC views.

When the page is loaded, I Render an

PartialView
inside a
div
.

<div id="#jobs">
@{
Html.RenderAction("Jobs", "Home", new { enviroment = "value" });
}
</div>


My action
Jobs
, looks like that (It's very simple):

public ActionResult Jobs(string enviroment)
{
var model = new MyModel();
model.Jobs = //Get Jobs...
return PartialView(model);
}


My Partial View just contains a table with all
Jobs
.

Then I have a HTML.DropDownList, wich contains my enviroments.
When this DropDownList changes it fires a JavaScipt function wich should update my Table inside my
Jobs div
.

The function looks like that:

function updateJobs() {
var selectedEnviroment = $("#enviromentsDropdown").val();

$.ajax({
type: "GET",
url: '@Url.Action("Jobs", "Home")',
data: {'enviroment': selectedEnviroment},
dataType: "html",
success: function (data) {
$("#jobs").html(data);
}
});
}


The function is working perfectly and
data
contains everything I want to have, but it's not updating my
Jobs <div>
.

If I instead put my data in another
div
it works without any problems.

Do you guys have any idea what I'm doing wrong and why it doesn't want to update my
Jobs div
?

Answer

Change <div id="#jobs"> to <div id="jobs">