I am currently generating some HTML in my jquery. The data is coming from a JSON file.
Here is my code creating said HTML:
$(document).ready(function () {
$('#searchForm').submit(function () {
var entry= $("#searchForm").val();
$.ajax({
type: 'POST',
url: '@Url.Action("myMethod", "myController")',
data: { 'entry': entry},
success: function (result) {
var jsonData = jQuery.parseJSON(result);
buildHTML(jsonData);
debugger;
},
error: function (result) {
debugger;
}
});
});
});
function buildHTML(jsonData)
{
var content = ' ';
$.each(jsonQC, function (i, item) {
content += //html generation here
});
$('#myDiv').html(content);
}
When I have the console open, the debugger stops the execution of my jquery. At the time the debugger line is hit, all of my html is displayed perfectly onto my view. When I let my code continue, all of the content is cleared from the page.
If it helps at all, here is my form code:
<form id="qcForm" action="">
<div class="row">
<div class="col-sm-4">
<div class="input-group">
<input id="searchForm" type="text" name="serverName" class="form-control" placeholder="Enter server name">
<span class="input-group-btn">
<button id="searchBtn" class="btn btn-default">Search</button>
</span>
</div>
</div>
</div>