1

I'm designing a web application using JSF 2.2, Primefaces 4 and jQuery 2.1, with jQuery being responsible for the ajax content loading and endless scroll.

The problem I'm hitting and can't seem to overpass is when I'm loading the content for the endeless scroll using the ajax command from jQuery. This creates new session instead of using the already existing one and is obviously not acceptable as it then makes JSF lose the stored data. The remaining code uses the .load() function for the other operations and works like a charm.

Can you give me a hand at understanding why this happens?


Here's the portion of the code used for the load and appending of new content:

$.ajax({ url: link, type: "GET", success: function(html) { if(html) { var result = $('<div />').append(html).find('#center_content_data').html(); $("#center_content_data").append(result); $('#center_content_data_loading').hide(); } } }); 

EDIT: I also tried to load the content using .post() and .get() but got the same result.

$.post(link, function(data){ $(data).find("#center_content_data").appendTo("#center_content_data"); }); 
3
  • jQuery doesn't create, read or use sessions in any way or form ? Commented Mar 17, 2014 at 14:58
  • No, all it does is to load additional content for the website, by replacing or appending new content. The endless scroll is the only part of the code that apparently causes the creation of a new session, specifically the portion showed above. Commented Mar 17, 2014 at 15:09
  • After days trying to solve the issue when i finally post a question about it I also came across something that led me to the answer. I'll post what was causing it as an answer, for anyone with a similar problem, as soon as stackoverflow allows me. Commented Mar 17, 2014 at 16:05

1 Answer 1

4

After days trying to solve the issue when i finally post a question about it I also came across something that led me to the answer.

The problema was caused by the link being loaded by ajax not being properly formatted (e.g. my.domain//app instead of my.domain/app), as the link was being generated by the application previous state. The browser was able to find the page but as it was a different domain than the one it originated the request was creating a new session for it.

To anyone experiencing a somewhat similar problem try to check these answers:

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.