I created an SharePoint Hosted App in this app I am using Two form for saving data into list. When I click on save button to save data into list data is saved into list and redirect to another page that have another form to save data into list but facing the error on that page-

Uncaught TypeError: Cannot read property 'split' of undefined dut to fail querystring parameter

I am using the following code to access appweburl and hostweburl-

hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));

var scriptbase = hostweburl + "/_layouts/15/";

var context = new SP.ClientContext(appweburl);
appContextSite = new SP.AppContextSite(context, hostweburl);
web = appContextSite.get_web();

What I have to do to fix this issue , please suggest anyone. Thanks in advance

1 Answer 1


The getQueryStringParameter function everyone copies from MSDN examples is not flawless;

It fails when there are no parameters (after the ? ) on the QueryString.

The function is totally unneeded anyway: What does this code getQueryStringParameter do?

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.