Link to home
Start Free TrialLog in
Avatar of Ivan Golubar
Ivan Golubar

asked on

Variable problem: Unexpected identifier

This is my code:
function show_btn(){
    var actualproject2 = new String('String');
    actualproject2 = <?php echo $_SESSION["actualproject"]; ?> ;
$.ajax({
  method:"POST",
  url: '/wp-content/themes/ne4/PJson.php',
  data:  {
    "getCanvas":1,
    "whichProject":actualproject2,
    },
    datatype: "text",
    success: function(strdate){
   console.log(strdate);
     }
 });
}

Open in new window


Uncaught SyntaxError: Unexpected identifier

In debugger I may see:
function show_btn(){
    var actualproject2 = new String('String');
    actualproject2 = First project;

Open in new window


I think the problem is blank space between "First" and "project", because it is also  underlined with red in debugger.
What correction must I perform to resolve this problem?
(i did try to solve it with:     var actualproject2 = new String('String');, but no success)
Avatar of Bill Prew
Bill Prew

If you are trying to assing "First project" to the string actualproject2 that you are creating, then:

function show_btn(){
    var actualproject2 = new String('First project');
}

Open in new window


»bp
Avatar of Ivan Golubar

ASKER

actualproject2 = <?php echo $_SESSION["actualproject"]; ?> ;

Open in new window


But debugger sees it as:  actualproject2 = First project;

Check attached image.
string.png
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial