Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to append content from a php file into a div with jquery mobile
    text
    copied!<p><strong>Goal:</strong> I'm trying to refresh content inside a div so that if the user is logged in, the page changes dynamically. </p> <p><strong>Progress:</strong> My first attempt was to use <code>$("#tab_b").load("php/tabs.php #tab_b");</code> but this didn't update the DOM so the jquery styling didn't get applied. Then I tried adding the .trigger('create') function <code>$("#tab_b").trigger('create');</code> This only led the style blink on and off for a fraction of a sec. Then I tried the .append() function which seems to work, I'm using the following code to test the function and this works:</p> <pre><code>$("#tab_b").html(''); $("#tab_b").append("&lt;button type='submit' data-theme='a'&gt;Test button&lt;/button&gt;").trigger('create'); </code></pre> <p>the only problem I have is fetching the content from the php file and then appending it to the div.</p> <p><strong>Content that should be refreshed:</strong> " #tab_b "</p> <pre><code>&lt;div id="tab_b" class="content_div"&gt; &lt;?php if(!isLoggedIn()) { ... } else { echo(" &lt;button type='submit' data-theme='a' id='logout' &gt;Logout&lt;/button&gt; "); } ?&gt; &lt;/div&gt; </code></pre> <p>Any idea's on how to do this? Also Any suggestions on improvements are welcome, I'm a beginner programmer.</p> <p>This question is an attempt to solve a bigger problem discussed in my other topic:</p> <p><a href="https://stackoverflow.com/q/9871111/1251989">jQuery Mobile does not apply styles after dynamically loading content</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload