Reputation: 971
All. I am using jquery. And I want to append element into loaded html from file (using "load"). It doesn't work.
Is it possible, to use append after load?
Upvotes: 0
Views: 2349
Reputation: 868
yes it is:
$("#myDiv").load("/Controller/View", function (responseTxt, statusTxt, xhr) {
if (statusTxt == "success") {
$("#myDiv").append('<input type="hidden" name="hdnText" value="8" />');
}
if (statusTxt == "error")
alert("Error: " + xhr.status + ": " + xhr.statusText);
});
Upvotes: 1
Reputation: 25796
You can use $.get
instead. $.load
is specifically for loading the returned data into an element such as a div.
$.get('url', function( data ){
$('#your-div').append( data );
});
Upvotes: 1