0

Can JQuery open SharePoint 2013 List Settings and make changes?

Likewise, can JQuery add web parts or add CSS to a Script Editor Web Part or CEWP?

If yes, where can I find information to do so?

Thanks-

1

The short answer, at least as far as making changes to list settings and adding web parts to pages, is yes.

(I'm not really so sure about editing the content of web parts like a SEWP or CEWP.)

However, the question "can jQuery do .... ?" is a bit misdirected/confusing. Yes, jQuery can do it, but only because jQuery provides the ability to make ajax requests and call SharePoint's REST API, which is the actual mechanism allowing you to interact with SharePoint in those ways. The way that question is framed makes it seem like the inability to do those things would be due to a shortcoming of jQuery, when in fact the ability or inability to do certain things is due to the functionality Microsoft has exposed (or not exposed) through the REST API.

The ability to interact with SharePoint's REST API from JavaScript is not unique to jQuery, you can also use other JavaScript libraries to do that, like axios.js, or JavaScript's own native XMLHttpRequest object, or the newer fetch API.

So really I think the way to reframe this question is like this:

Q1 - Is there a way to change SharePoint 2013 list settings or add web parts from JavaScript?

A1 - Yes. SharePoint 2013 exposes a REST API that you can call from JavaScript that will allow you to work with lists and add web parts to pages, among many other things.

Q2 - Ok, that's great, so then my follow up question is: does the jQuery JavaScript library provide any tools that I can use to call SharePoint's REST API?

A2 - Yes. jQuery's ajax function can be used to make AJAX requests to SharePoint's REST API and interact with SharePoint in that way. In addition, there are other ways to make AJAX calls to SharePoint's REST API from JavaScript:

  • JavaScript's native XMLHttpRequest object (no additional libraries necessary, this is vanilla JavaScript.)
  • JavaScript's newer (but also native) fetch API. (Also no additional library needed, as long as the code is running on a newer browser that implements the newer fetch API.)
  • Other JavaScript libraries that provide AJAX functionality, for example, axios.js (and there are others too).

If yes, where can I find information to do so?

I have provided a few links here to some of Microsoft's documentation about the REST API, but in general, I think the way you could find out more information is by searching to find out if the functionality you want is possible using the REST API, like:

or

and once you start finding answers that way, figure out how to use jQuery's ajax syntax to make those requests. (I can assure you, many of the examples you will find will already be using jQuery, it's quite popular.)


Edit to add:

OP's question, the way it is framed, because it mentions jQuery specifically, led me to assume that the OP may be either required to use jQuery or is looking for a more generic way to access SharePoint through JavaScript, hence my mentioning the REST API.

However, since I reframed the question as basically "how can I interact with SharePoint from JavaScript", I feel I would be remiss if I did not mention that Microsoft provides its own proprietary JavaScript library meant specifically to interact with SharePoint, known as the "SharePoint JavaScript Client Object Model", or more frequently: the JSOM.

I will admit, I did not include it in my original answer because I am personally biased against the JSOM - I very much dislike the coding syntax. I find it somewhat confusing and un-intuitive, and personally I try very hard to avoid it.

That being said, it's worth noting that there are some things you can accomplish through the JSOM that you cannot do through the REST API.

For that reason, I felt I should append my answer to include it as an option for accessing SharePoint from JavaScript.

(Also, note for OP - if you use the JSOM you do not necessarily need jQuery. They can be used in conjunction, of course, but neither is dependent on the other.)

I have included one link here to some MS documentation on the JSOM, and of course you can find plenty of other information and examples out there by searching for "sharepoint jsom".

| improve this answer | |
  • Dylan! Thank you so much for this studied and thorough reply! This will help launch my learning plan. Cheers! – ChasEpes Sep 25 at 11:56
  • @ChasEpes appended my answer with another option for you. – Dylan Cristy Sep 25 at 15:19

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.