I'm trying to do is to get my accordion to work using MVC. All I did was use the template of visual studios 2013 and added a view and put my html, javascript, jQuery code in the view because it worked in notepade++. I imported the scripts and everything.
What my program is trying to do is to do a simple Ajax to some local txt file data I have saved on my computer the data in the txt is put in a JSON format so my call should be working. But when I run my program IE doesn't even go to the call or maybe it goes to the call and doesn't work. When I remove the call completely and put an alert box in its place it reaches the alert but when I re-insert the ajax it doesn't call it.
So here is my code - what am I doing wrong?
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<link href="/Content/themes/base/jquery-ui.min.css" rel="stylesheet" />
<body>
<div id="container">
</div>
<script src="Scripts/jquery-1.11.2.min.js"></script>
<script src="Scripts/jquery-ui.js"></script>
<script>
$(function () {
$.ajax({
url: "AccordianData.txt",
contentType: "application/json; charset=utf-8",
type: "GET",
dataType: "json",
success: function (data) {
for (var x = 0; x < data.numHeaders; x++) {
$("#container").append("<h2>" + data.headerTitle[x]+ "</h2>");
$("<div><p>'" + data.content[x]+ "'</p></div>").appendTo("#container");
}
$("#container").accordion();
},
error: function (xhr) {
console.log("Ajax or parse error");
}
})
//$( "#container" ).accordion();
});
</script>
</body>
aye I solved my own problem. the @Scripts.Render("~/bundles/jquery") in my Layout folder was conflicting with the jquery script I had placed in my index view so once I removed it. the accordion showed up correctly and the Ajax call was made