Note that there are some explanatory texts on larger screens.

plurals
  1. POSend user details (session token) within every AJAX requests (Sencha Touch 2)
    primarykey
    data
    text
    <p>i am building a Sencha Touch 2 Application with userspecific datasets. </p> <h3>Architecture of the App:</h3> <p>Sencha Touch App &lt;=====> Java Server backend with REST Services ( many AJAX requests =) )</p> <p>What i actually have is:</p> <ul> <li>Login the user with username/password <blockquote> <p>The app gets initialized and the loginform comes into play. After submitting the form as a AJAX request, the server backend checks the userdata and calls the client callback function. </p> </blockquote></li> </ul> <p>And what i want to do is:</p> <ul> <li>The callback function should <ol> <li>create a cookie with the sessiontoken <em>or</em></li> <li>store the sessiontoken within the localstorage (<a href="http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.LocalStorage" rel="noreferrer">http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.LocalStorage</a>) <em>or</em></li> <li>store the sessiontoken within js variable</li> </ol></li> </ul> <p>Okay, shouldn't be the problem.</p> <p><strong>But how can i achieve the following:</strong></p> <p>Most of the data is <em>specific for one user</em> and should be returned by the REST service if needed (by clicking on the navigation,...). How can i send the sessiontoken (see above) within every AJAX request - so the server can provide the suitable datasets (assuming the token is valid)?</p> <p><strong><em>Send cookies within AJAX requests</em></strong></p> <p>I have already read that cookies gets automaticly added to the request if the url is on the same space, right? The Java Server is on the same domain (localhost:8080) but the cookies aren't available - instead of requests on urls like 'app.json'. I thought that cross-domain-requests are really domain specific?</p> <p><strong><em>Send paramaters within AJAX requests</em></strong></p> <p>Because the cookies aren't avi i thought about the possiblity of 'manually' adding parameters to the ajax requests. The App will contain many AJAX requests and thats why i dont want to add the token manually - i tried to override the requests function of <em>Ext.Ajax</em> but i failed ;-( :</p> <pre><code>(function() { var originalRequest = Ext.data.Connection.prototype.request; Ext.override(Ext.data.Connection, { request : function(options) { alert("Do sth... like add params"); return originalRequest.apply(this, options); } }); })(); </code></pre> <p>ERROR:</p> <blockquote> <p>Uncaught Error: [ERROR][Ext.data.Connection#request] No URL specified</p> </blockquote> <p>I also tried to add a listener</p> <pre><code>Ext.Ajax.add({ listeners : { beforerequest : function( conn, options, eOpts ){ alert("Do sth... like add params"); } } }); </code></pre> <p>ERROR:</p> <blockquote> <p>Uncaught TypeError: Object [object Object] has no method 'add' </p> </blockquote> <p>Any idea about how i can add the token?</p> <p>Or any better way of handling these case?</p> <p>Thanks!</p>
    singulars
    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