1

I'm loading a view, extra.php, into #extra div via jquery command:

$('#extra').html("<?php $this->load->view('extra'); ?>");

extra.php is a long file, and jquery.html() loads only a single line of code

for example, it loads fine:

<table><tr></tr><tr></tr><tr></tr></table>

but it doesn't load at all:

<table>
<tr>....</tr>
<tr>....</tr>
<tr>....</tr>
</table>

How to fix it?

5
  • 1
    Does it matter if it loads it in one line? I mean, why you display it it will display just fine, or are you planning something else with it? Commented Jun 25, 2012 at 7:46
  • 1
    Is the issue that it will only load the first line, or that it loads the entire page as one line? Are you getting all of the data or is something not getting loaded? Commented Jun 25, 2012 at 7:51
  • 1
    if you are wanting closer look at source, do it in a browser console where DOM is all neatly packaged in expandable tree, indentation/formatting in source isn't critical Commented Jun 25, 2012 at 7:52
  • @charlietfl - That assumes the OP is getting all data, just not tidy via "view source". Is that due to how codeignitor outputs html, or jquery's .html(), or more likely that the extra.php in question is outputting all as one line? Just curious if you know where the minifying is taking place. Commented Jun 25, 2012 at 7:58
  • @Anthony lack of line breaks in php would do it, jquery will retain formatting Commented Jun 25, 2012 at 8:00

2 Answers 2

1

Ok guys, I found some extra solution on codeigniter board, it's simply hilarious:

http://codeigniter.com/forums/viewthread/219780/

: )

Sign up to request clarification or add additional context in comments.

Comments

0

You need to escape each line that is output from the view, that way you can pass a multi-line string to the function. To escape, you just need to append a \ to the end of each line so that you would have the following:

$('#extra').html("<table>\
<tr>....</tr>\
<tr>....</tr>\
<tr>....</tr>\
</table>");

You can see it working on jsfiddle.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.