DN0300 DN0300 - 4 months ago 7
Javascript Question

Loading a page in div using jquery and ajax

I am trying to open content into a div on click, I can't figure out where I am going wrong any help is much appriciate. Thank you

Html:

<li><a id="hrefid" href="#link">Link</a></li>

<div id="content"> </div>


Jquery:

$('#hrefid').on('click', function (e) {
var load = $(e.target).attr("href");
if(load == "#link") {
$.ajax({
type: 'post',
url: "/page/test/272.html",
complete: function (event) {
$("#content").contents().remove();
$("#content").append(event.responseText);
}
});
}
});

Answer

Your intended operation is a GET operation as far as i understand, so instead of type: 'post' make it type: 'get'

Comments