How to retrieve Query String Value using JQuery in SharePoint Online?

This SharePoint JQuery tutorial I will explain how to retrieve a Query String Value using JQuery in SharePoint Online Office 365. Here I have a SharePoint web part page which has a query string parameter, I want to retrieve the query string value using jQuery on the page load.

Retrieve Query String Value using JQuery

Here I was having a SharePoint web part page, where the query string parameter name is “MyID” and my web part page URL is like below:

https://onlysharepoint2013.sharepoint.com/sites/TSInfoIntranet/SitePages/MyDemoWebPartPage.aspx?MyID=5

Below is the jQuery code which we can use to retrieve the query string parameter value.

<script>
$(document).ready(function () {
var id = GetParameterValues('MyID');
if(id)
{
alert(id)
}
else
{
alert('No Query String Available')
}

});

function GetParameterValues(param) {
    var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < url.length; i++) {
        var urlparam = url[i].split('=');
        if (urlparam[0] == param) {
            return urlparam[1];
        }
    }
}
</script>

Here in this JQuery code, I have created a variable as “id” which is present inside the ready function[ready()]. In that “id” variable, I have passed the “MyID” get parameter values. The code is given below-

var id = GetParameterValues(‘MyID’);

Then after I created a function with function name and having parameter as-

[function GetParameterValues(param)]

In that function, I have used the “for loop” condition for retrieving the Query String Value.

No item exists at URL. It may have been deleted or renamed by another user

This SharePoint tutorial, we will learn how to fix the error, No item exists at URL. It may have been deleted or renamed by another user.

Recently I was trying to access a web part page in SharePoint online with a query string parameter. But when we enter to open the page it gave an error saying: Sorry, something went wrong. No item exists at https://url. It may have been deleted or renamed by another user. The error looks like below.

I just created a web part page in SharePoint online and when I open the page it opened correctly. But if I added a query string parameter like ID=5, it throws the error.

https://onlysharepoint2013.sharepoint.com/sites/Raju/SitePages/UpdateWebPartPart.aspx?ID=5

Here in this screenshot, it is clearly telling that “No item exists at that URL where ID=5”. So the solution of this problem is given below-


jsom sharepoint 2013 examples
jsom sharepoint 2013 examples

No item exists at URL. It may have been deleted or renamed by another user

We can not use “ID” in the query string in SharePoint because the “ID” is already reserved Query String Parameter in the SharePoint Site.  So we have to take another parameter name, here I have modified the “ID” to “MyID”. After changing the ID to MyID, I can access the URL.

https://onlysharepoint2013.sharepoint.com/sites/Raju/SitePages/UpdateWebPartPart.aspx?MyID=5

So we can not use the reserved keywords for Query String Parameter in SharePoint. Below are the words which you should not use as QueryString parameter name.

  • FeatureId
  • ListTemplate
  • List
  • ID
  • VersionNo
  • ContentTypeId
  • RootFolder
  • View
  • FolderCTID
  • Mode
  • Type
  • PageVersion
  • IsDlg
  • Title
  • _V3List_

So these are the Query String Parameter which is already reserved in SharePoint Site. Hence we can not use these reserved parameters in SharePoint.

This is how we can fix error, No item exists at URL. It may have been deleted or renamed by another user which comes in SharePoint 2013/2016.

You may like following jQuery SharePoint tutorials:

In this tutorial, We discussed how to retrieve a Query String Value using JQuery in SharePoint Online Office 365.

  • Superb blogs by you…keep growing like this….waiting for your blogs ….always…..love the way of explanation….keep it up…..

  • My parameter has %20 in it because of spaces, can you show how to remove the spaces? Also, instead of Alert output, how can I display on the page?

  • >