I am using JQuery to invoke a jsp page using Ajax. It works fine when I put just a DateTime in the JSP and the Ajax call is able to show the content of this JSP i.e. DateTime but when I put the Ad code inside the same JSP which was displaying DateTime, I get a page which just only displays the Ad and rest of the content goes away.
I want the Ad to be displayed at a specific location of the page using an Ajax call if the user changes the certain field from a page e.g. the price.
Below is my requirement:
PageA.jsp —> Ajax call is invoked if the user changes the price inside a text box from PageA.jsp page using JQUery or any JavaScript Framework—> AdCall.jsp page is loaded at a certain div at page PageA.jsp.
Below is the code I am using:
function makeAnAdCall(field) {
$.ajax({
url : "AdCall.jsp",
success : function (data) {
$("#content").html(data);
}
});
}
This is the area where I am displaying the Ad:
<div id="content" style="color:blue;font:bold 14px arial;padding-top:140px;"> Here!
</div>
One of the reason why it is showing just an ad could be because the ad is trying to write the full document write object instead of just writing the specific area. But I am sure there got to be work around for it 🙂 Any suggestion?
I was able to solve this problem by using the writeCapture JavaScript framework. The framework has plugin for JQuery but it can be used without JQuery as well. The only change you have to do is instead of calling the JQuery
$("#content").html(data);use$('#content').writeCapture().html(data);