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?

  • Is getdetails(); function returns something? If yes then add the whole code in the comment. – Ram Apr 19 '16 at 5:51
  • getdetails() will return ID number – user52650 Apr 19 '16 at 5:55
  • You need to only return your result. – Ram Apr 19 '16 at 7:06
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?

| improve this answer | |
1

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

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

| improve this answer | |
0

Please check the getdetails function.Code is inside ()

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

Please try below mentioned code.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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