0

Below Code giving an error called

"expected identifier in function getdetails"

$( document ).ready(function() { 

    qString = getdetails();
});


function getdetails( {
 var result = window.location.href.split("?ID=")[1];
 return result;
});

Can you please assist me to resolve it?

3
  • Is getdetails(); function returns something? If yes then add the whole code in the comment.
    – Ram
    Commented Apr 19, 2016 at 5:51
  • getdetails() will return ID number
    – user52650
    Commented Apr 19, 2016 at 5:55
  • You need to only return your result.
    – Ram
    Commented Apr 19, 2016 at 7:06

4 Answers 4

2

Your code fails because the Function declaration is wrong:

You do:

function getdetails( {dosomething} )

But the correct way of declaring a function is:

function getdetails() {dosomething}

BUT, More potential errors:

Your code tries to extract the ID value when it is the first QueryString parameter in the URL

So it fails:

  • When ID is not immediatly after the ? QueryString identifier

  • When there is no ID in the QueryString

SharePoint provides you at least 4 ways of getting a QueryString value:

What does this code getQueryStringParameter do?

1

var result; $( document ).ready(function() { getdetails(); var qString = result; });

function getdetails() { result = window.location.href.split("?ID=")[1]; return result; }

0

Please check the getdetails function.Code is inside ()

 function getdetails(){ var result = window.location.href.split("?ID=")[1]; return result;};
0

Please try below mentioned code.

var result;
$( document ).ready(function() { 
     getdetails();
     var qString = result;
});

function getdetails() 
{
   result = window.location.href.split("?ID=")[1];
}
3
  • qString = getdetails();....control is not reaching the functn
    – user52650
    Commented Apr 19, 2016 at 6:18
  • I have edited my answer. Please try it.
    – Hardik
    Commented Apr 19, 2016 at 6:36
  • Is that working for you?
    – Hardik
    Commented Apr 19, 2016 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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