J-H
J-H

Reputation: 1869

Jquery append ajax load after div tag

im trying to insert a ajax loaded content after a div tag

$('#optionheader').after($.load('calendar', {'requestType':'loadMenu'}));

can anybody tell me where the error is?

thx

Upvotes: 0

Views: 1519

Answers (2)

Andy Ecca
Andy Ecca

Reputation: 1969

Try

     var div = $("<div />");
     div.load('calendar', {'requestType':'loadMenu'});
     $("#optionheader").after(div);

Upvotes: 1

thefreeman
thefreeman

Reputation: 1035

You can use $.get for this:

$.get('/calendar', {'requestType':'loadMenu'},function(data) {
    $("#optionheader").after(data);
});

If you want to do it your way, with .load, you could do it like this

$("#optionheader").after($('<div />').load('/calendar',{'requestType':'loadMenu'});

This should add a div to the #optionheader tag and load it with the result of /calendar

Upvotes: 1

Related Questions