Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

this code gives me an error saying "Uncaught SyntaxError: Unexpected string" on line:

"$("#mainPage").load('pages/' . name . '.php');" 

why? should i show the entire page code?

$("#mainPage").fadeTo(500, 0, function() {
    name = $(button).attr('name');
    $("#mainPage").load('pages/' . name . '.php');
    var page = "pages/" .name. ".php";
    var state = {
      "canBeAnything": true
    };

    history.pushState(state, "new Page", "main.php?page="+page);
});
share|improve this question
1  
+ is concatenation operator in Javascript, as against . in php – karthikr Aug 10 '14 at 19:50
up vote 9 down vote accepted

JavaScript uses + for concatenation, not .

Additionally, you should use var name = ... instead of just name = ... to avoid creating a global!

share|improve this answer

You used PHP style concatenation, instead of Javascript style for that line.

$("#mainPage").load('pages/' + name + '.php');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.