1

When I call a PHP file using,

var xhr = new XMLHttpRequest();
xhr.open('POST', 'file.php');
xhr.setRequestHeader('Accept','*/*');
xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');
xhr.onload = function() {
document.getElementById('container').innerHTML = xhr.responseText;
};

the responseText doesn't include jQuery.ajax call in file.php. However when I do this same thing using

jQuery.ajax{( 
url: 'file.php', 
type: 'post',
success: function (data) { jQuery('#container').html(data); }
)};

The data includes jQuery.ajax call in file.php.

I am trying to figure out why XMLHttpRequest won't do this for me.

LJS
  • 33
  • 4
  • 1
    possible duplicate of [Executing – OneOfOne Sep 07 '13 at 10:54
  • This has nothing to do with XMLHttpRequest. It is all about `innerHTML` – Quentin Sep 07 '13 at 11:43
  • @Quentin You were right, I replaced innerHTML with jQuery.html and it worked fine. Thanks for the suggestion. – LJS Sep 07 '13 at 12:36

0 Answers0