I've been working on a web page with php + smarty + jquery + html.
The problem, I need to display the diferent content of a web page using the window.location = mainPAge.php insted of $("#div-Page").show()
In other projects I make a simple switch like this:
$(document).ready(initialize);
function initialize{
showPage("none");
}
function showPage(page){
switch (page) {
case "none":
$("#mainDiv").show();
$("#webDiv2").hide();
$("#webDiv3").hide()
break;
case "opcion2":
$("#mainDiv").hide();
$("#webDiv2").show();
$("#webDiv3").hide();
break;
case "opcion3":
$("#mainDiv").hide();
$("#webDiv2").hide();
$("#webDiv3").show();
break;
}
And it work perfectly, but now I cant use this, I need to use the pages from php directly so I use this:
$(document).ready(initialize);
function initialize{
showPage("none");
}
function showPage(page) {
switch (page) {
case "none":
window.location = "mainContent.php";
break;
case "opcion2":
window.location = "secondContent.php";
break;
}
The problem !!! It seems that when I mix jQuery "$(document).ready(initialize)" with "window.location = 'mainContent.php'" the browser goes into an infinite loop.
I really dont know why and less how to avoid the loop, if i dont try to show mainContent.php at the begining of the page, and I asigned a button to show the mainContent.php, that way work perfectly.
But I need to display mainContent.php for automatic way to start page.
I appreciate so much your suggestions.
Regards !!!!
Aucun commentaire:
Enregistrer un commentaire