1
I’m using history API to load the clicks in the menu, in a div #content, ok so far so good, but I’m handling the errors by JQUERY even look only
$('a').click(function() {
pageurl = $(this).attr('href');
if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl);
}
$('#conteudo').load($(this).attr('href'), function(responseText, statusText, xhr)
{
if(xhr.status == 403) {
$('#conteudo').load("/error/error403");
}
if(xhr.status == 404) {
$('#conteudo').load("/error/error404");
}
if(xhr.status == 405) {
$('#conteudo').load("/error/error405");
}
});
return false;
});
I would like to know if this is really feasible, since I am using VRAPTOR and I can only imagine this way of treating errors in a "efficient" way someone there had problems or can see a possible problem?
if this is relevant, if the controller does not exist it sends the non-existent page error(404), if the user tries to access an unauthorized method, returns the 403(Forbidden) and so on..
EDITED FOR question 2:
well, I have the following structure
I have index.php which contains 2 Divs
<div id="menu">
e <div id="conteudo">
when you load the index, it pulls . load(/test/menu) to the div=menu
and when I click on any link in the menu, it triggers the function giving $("#content"). load(/test/Linkclicked)
works perfectly, only that if I type in the browsed /test/Linkclicked or /test/menu, it will simply open only the respective ones without the correct division, the linkClicate will open only the html referring to it without the MENU above... and so if I open the link of the /test/menu, it will show only the menu without the contents
how do I so that when I open the /test/Linkclicked it opens the COMPLETE page that would be the /test/index, but in the position referring to the link typed in the case /test/Linkclicked
Why, truth had not even thought of this detail, it was worth taking advantage of the package, you would recommend another form of control or is sufficiently "good"?
– user2582318
I’m going to need a little more context. What exactly do you mean?
– Bruno Augusto
added in the question Edit, if you can take a look, thank you, thanks
– user2582318
I understood I think, I would put a header in the index, if the server received header means q came from the clicked links then do as scheduled, otherwise the user typed and gave enter, then sends something q knife load in the /menu, right?
– user2582318
Maybe that can help you make a control.
– Bruno Augusto