Reputation: 133
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");
});
Upvotes: 1
Views: 2877
Reputation: 133
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:
Upvotes: 4