tags:

views:

107

answers:

3

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.

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
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
+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
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
You sir, are a hero. That is what the problem was. I have been fighting this for weeks.
Matthew
Excellent, it solved your problem. Get rid of those closing tags.
karim79