As the title says, can I create a SharePoint-Hosted App and make Ajax calls right away? or do I have to import an ajax library or something like that?

2 Answers 2


Ajax has nothing to do with jQuery per se.




jQuery has a function which wraps around JavaScript native 'Ajax' calls

    type: "POST",
    url: "webservice",
    data: "a=1&b=2&c=3",
    success: function(d) {

But this exact functionality can be written without jQuery as:

var r = new XMLHttpRequest(); 
r.open("POST", "webservice", true);
r.onreadystatechange = function () {
    if (r.readyState != 4 || r.status != 200) return; 
  • 1
    I am in school for another 6 months :D, I tried the XMLHttpRequest, and I realized I'm trying to post/put to a (http) from a (https) and that doesn't work.. does SP.Webproxy solve this? because it worked when I was GETting data from the same webservice using the SP.webproxy.
    – Dr Cox
    Commented Sep 16, 2015 at 7:55
  • GET and POST are protocols, Ajax only means you can execute them async. The POST protocol has (ofcourse) many security restrictions, search for Cross Domain blogs (and quit school now) Commented Sep 16, 2015 at 8:51
  • 2
    There are some pitfalls of coding directly against XMLHttpRequest though... especially if you need cross-browser compatibility (which everyone does...) check out the jQuery ajax source code (ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.js -- search for ajax: function( url, options ) Although I like thought of just plugging into RequestExecutor
    – John-M
    Commented Sep 21, 2015 at 1:40

No Its not built in, you need to add reference to jQuery - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> to the head of the script tag.

You can also use SP.RequestExecutor.jsto replace ajax calls.

executor = new SP.RequestExecutor(siteurl);

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.