load file as part of a js script
<p>I have this script in the head of my page :</p>

<pre><code>&lt;script type="text/javascript"&gt;

    jQuery.PictureSlides.set({

            /* some settings here */

                images : [
        &lt;?php include"01.inc.txt"; ?&gt;
            /* myfile is an array, loaded as default file when user first reads the page, and looks like :
                {
                image : "001.jpg", 
                alt : "Name #1",
                text : "Title #1",
                desc : "Desc #1"
                },
                {
                image : "002.jpg", 
                alt : "Name #2",
                text : "Title #2",
                desc : "Desc #2"
                },
           and so on... */
        ]
            /* some other settings here */
&lt;/script&gt;
</code></pre>

<p>Then, in the body, I have my menu :</p>

<pre><code>   &lt;ul id="main-nav"&gt;
    &lt;li&gt;
     &lt;a class="main-link" href="#"&gt;Home&lt;/a&gt;
    &lt;/li&gt;

    &lt;li&gt;
     &lt;a class="main-link" href="#"&gt;Main Link&lt;/a&gt;
      &lt;ul class="sub-links"&gt;
        &lt;li&gt;&lt;a href="01" id="link-1" class="menuloader" title=""&gt;link&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="02" id="link-2" class="menuloader" title=""&gt;link&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="03" id="link-3" class="menuloader" title=""&gt;link&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="04" id="link-4" class="menuloader" title=""&gt;link&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
   &lt;/ul&gt;
</code></pre>

<p>My questions are :</p>

<ul>
<li>Is it possible to have a click on any link of the menu, and then the corresponding file ("01.inc.txt" or "02.inc.txt"...) loaded/read by the script, without refreshing the page ?</li>
<li>If "yes", what would be the best way, what can I sart with, or what shall I start looking for in the doc ?</li>
</ul>

<p>EDIT II : so, according to your answers, this would be a good start ?</p>

<pre><code>$(document).on('click', '.menuloader', function(){

var thisId = $(this).attr('id');

    $.ajax({
    type: "POST",
    url: "addfile.php", /* here, I open my file (identified as "thisID") with PHP, parse it, read lines, then send them back ? */
    data: "file_id="+thisId
    }).done(function(data) { /* get results here ? like =&gt; images : [ {data ?} ] */ });
});
</code></pre>
