Note that there are some explanatory texts on larger screens.

plurals
  1. POpageinit and jquery ajax call
    primarykey
    data
    text
    <p>In my page test.html I use pageinit, which call functions from exem.js, the alert in the beginning of functions are displayed, I maean that the functions are well called, but ajax call does not work!! Also if I test the ajax call in test.html without pageinit and exem.js, the code is working, I mean that the two functions are correct. This is my code: test.html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;title&gt;jQuery Mobile: Demos and Documentation&lt;/title&gt; &lt;link rel="stylesheet" href="jquery.mobile-1.0.1.min.css" /&gt; &lt;link rel="stylesheet" href="jqm-docs.css" /&gt; &lt;script src="jquery.js"&gt;&lt;/script&gt; &lt;script src="jquery.mobile.themeswitcher.js"&gt;&lt;/script&gt; &lt;script src="jqm-docs.js"&gt;&lt;/script&gt; &lt;script src="jquery.mobile-1.0.1.min.js"&gt;&lt;/script&gt; &lt;script src="exem.js"&gt;&lt;/script&gt; &lt;script&gt; $('#myPage').live('pageinit', function(event) { alert("pageinit working"); jQuery.noConflict(); getCategories (); getnameCategories (); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="myPage" data-role="page"&gt; &lt;!-- L'entete du page --&gt; &lt;div data-role="header"&gt; &lt;h1&gt;Identifiez-vous&lt;/h1&gt; &lt;a href="#search" data-role="button" data-theme="e"&gt;Config&lt;/a&gt; &lt;a href="acceul.html" data-role="button" data-theme="e"&gt;Accueil&lt;/a&gt; &lt;/div&gt; &lt;!-- Le contenu du page --&gt; &lt;div data-role="content" id="li"&gt; &lt;ul data-role="listview" data-inset="true" data-theme="e"&gt; &lt;li id="a1" &gt;&lt;img src='img1' alt="Categ" class="ui-li-icon"/&gt;&lt;a id="im1" href="AuthentificationCreation.html"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="a2"&gt;&lt;img src='img2' alt="Categ" class="ui-li-icon"/&gt;&lt;a id="im2" href="AuthentificationCreation.html"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="a3"&gt;&lt;img src='img3' alt="Categ" class="ui-li-icon"/&gt;&lt;a id="im3" href="AuthentificationCreation.html"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="a4"&gt;&lt;img src='img4' alt="Categ" class="ui-li-icon"/&gt;&lt;a id="im4" href="AuthentificationCreation.html"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="a5"&gt;&lt;img src='img5' alt="Categ" class="ui-li-icon"/&gt;&lt;a id="im5" href="AuthentificationCreation.html"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li id="a6"&gt;&lt;img src='img6' alt="Categ" class="ui-li-icon"/&gt;&lt;a id="im6" href="AuthentificationCreation.html"&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;!-- Le pied du page --&gt; &lt;div class="ui-bar-a"&gt; &lt;div data-role="footer" data-position="fixed" data-theme="a"&gt; &lt;div data-role="navbar" &gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#search" data-icon="delete"&gt;Cat&amp;eacute;gories&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" data-icon="delete"&gt;Compte&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" data-icon="delete"&gt;Panier&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- /navbar --&gt; &lt;/div&gt;&lt;!-- /footer --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>exem.js:</p> <pre><code>var idCategories = new Array(); var nameCategories = new Array(); var ws_key="my_key"; var PHP_AUTH_USER=""; function getCategories () { alert("fn1"); jQuery.ajax({ type: "GET", async: false, url: "http://my_site/api/categories?ws_key="+ws_key+"&amp;PHP_AUTH_USER="+PHP_AUTH_USER, dataType: "xml", success: parseXml }); function parseXml(xml) {var i=0; jQuery(xml).find("category").each(function() { idCategories[i]= jQuery(this).attr('id'); alert("studentName="+idCategories[i]); i=i+1; }); } } function getnameCategories () {alert("fn2"); for(i=1;i&lt;idCategories.length;i++) { jQuery.ajax({ type: "GET", async: false, url: "http://my_site/api/categories/"+idCategories[i]+"?ws_key="+ws_key+"&amp;PHP_AUTH_USER="+PHP_AUTH_USER, dataType: "xml", success: parseXml }); function parseXml(xml) {alert("success"); jQuery(xml).find("name").each(function() { nameCategories[i]= jQuery(this).find('language')[0].firstChild.data; alert("aaa="+i+"aa"+nameCategories[i]); }); } jQuery('#im'+i).html(nameCategories[i]); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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