Reputation: 11
jQuery(document).ready(function() {
jQuery('.bnr').each(function() {
var group = jQuery(this).attr('adgroup');
var obj = jQuery(this);
jQuery.get("http://www.example.com/ads.php",
{ 'adGroup': group },
function( response ) {
obj.html( response );
}
);
})
});
I'm trying to load ads using jQuery. The ads.php return affiliates code. Problem is when the return response is javascript. All works only if response is html. Using eval() do not work or i'm missing something. response example:
<script type="text/javascript" src="http://adserving.unibet.com/ad.aspx?pid=1234&pbg=123">
Upvotes: 1
Views: 329
Reputation: 44740
You can also try this way
jQuery('.bnr').each(function() {
var group = jQuery(this).attr('adgroup');
var obj = jQuery(this);
$.ajax({
url: 'http://www.example.com/ads.php',
data: { 'adGroup': group },
dataType: "text/html", // this will make sure that your response is html
success: function(data){
obj.html( data );
}
});
});
Upvotes: 0
Reputation: 388316
Use .load() to load dynamic content from a url
jQuery(document).ready(function() {
jQuery('.bnr').each(function() {
var group = jQuery(this).attr('adgroup');
var obj = jQuery(this);
obj.load("http://www.example.com/ads.php", { 'adGroup': group })
})
});
Upvotes: 1