I've had this problem for a while, and I've isolated it to being caused the mysql_connect or mysql_select_db function. For some reason, when I use jquery's .load(), the response text will have a line break at the top when displayed in the page (in a <textarea>
, for instance, but in any element). Looking at the response in Firebug, there is no line break. And if I just put plain text in the script that I'm calling, the line break doesn't show up. It has something to do with the connection to the database that the script I'm calling is making. The line break will even show up if I write it to console.log(). I'm completely flustered, and I hope this description of the problem makes sense. If not, I'll be happy to clarify.
views:
107answers:
3
A:
For the most part all the load function does is call the ajax function and appends the data. See if this code gives you the line break.
// Request the remote document
jQuery.ajax({
url: url,
dataType: "html",
complete: function(res, status){
alert(res.responseText);
}
});
bendewey
2009-03-04 20:59:42
Yep, it also shows up in the alert when I do that. I'm gonna get to the bottom of it and I'll post my results back here for anyone else in the future that has the same problem.
Matthew
2009-03-05 14:42:59
+1
A:
I did some playing around this morning, and found out what was happening. It seems that having one include() in the PHP script that I was calling was fine, but for every additional include(), it would add a line break! Don't ask me why. Hopefully someone here can provide some insight into this behavior. (The same thing happens if I nest the includes() inside of another single include() file.)
Matthew
2009-03-05 14:59:19
A:
Could it be related to whitespace or linebreaks after the closing (?>) tags in one or more of the included files? I would check that as from experience, I know that PHP does not like whitespace after closing tags.
karim79
2009-03-16 14:58:17