Jquery call from Content Editor Web Part RRS feed

  • Question

  • I am calling an external web service from Content editor web part from SharePoint Online.

    The code is 

    <HTML> <Head> <script type="text/javascript" src="https://ajax.microsoft.com/ajax/jquery/jquery-1.6.2.min.js"></script> <script type="text/javascript"> function test() { $.ajax({ url: "https://google.com/somewebservice", dataType: "jsonp", success: function(json) { alert(json.name); }, complete: function(xhr, json) { alert("Done"); },

    error: function( xhr,err ) {




    }</script></Head><Body><button onclick="test()"> Button </button></Body></HTML>

    the success function doesn't execute. Only the complete executes. When I debug it, I can see a call being made to the web service but there is no response to it.

    If I execute the same code as an html document, then the code works as required.

    Please let me know what I might be missing to make it work on SharePoint Online aka SharePoint 365

    ----There is a weird behavior. When I try to debug the code in IE Developer tools, after stepping through each statement, the success function gets executed. But if I run without debugging, error function is executed and the value is "parseerror". "xhr" object in the error has statusText as "success" and 200 HTTP code.

    • Edited by newSharepointDev Friday, July 20, 2012 1:54 AM Updated the information
    Thursday, July 19, 2012 1:35 AM