I have a PHP file which returns MySQL results based on post information from an AJAX request. I have it set to echo the information from the MySQL table. So, I want to know how to load that response text into a DIV with JQuery. If I look in Firebug, the response text is exactly what I expect, the results of the MySQL query, so I know PHP is doing its job.
In its most simple form (as your question... ;))
$(<selector for the div>).load("url of the php-file");
Hmm, plain JavaScript? Maybe you can try this:
var callback = function (response) { var myDiv = document.getElementById("resultsDiv"); var textElem = document.createElement('pre'); textElem.innerHTML = response.text; myDiv.appendChild(textElem); } Ajax.request(url, params, callback); // or whatever you use for your Ajax query
This basically would create a callback function. So when you make your ajax call (you didn't say how), pass the result to your callback function (so your javascript won't block the page while loading results).
A new <pre> element will be created, text inserted in it, and the element inserted in your (already provided) resultsDiv.
Text in a <pre> element is displayed in a fixed-width font like Courier and it preserves line breaks and spaces (in case you formated the text on the server, othervise you can create a span or div instead).