How to use jQuery

    General discussion

  • Hi, I want to use jQuery on my code

    I try this plugin : http://nivo.dev7studios.com/support/jquery-plugin-usage/

    But there is error on jQuery :

    Unhandled exception at line 3, column 31871 in ms-appx://d620fd90-1a7b-412a-a3e2-a6fa17e09017/js/jquery-1.7.1.min.js

    0x800c001c - JavaScript runtime error: Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement.  For more information, see http://go.microsoft.com/fwlink/?LinkID=247104.

    How to fix this?


    Tuesday, September 11, 2012 5:45 AM

All replies

  • Microsoft set this rule to avoid unknown generation of dynamic content (so if you connect to a 3rd party service, that service won't be able to inject malicious content into your app). So you have two options:

     - Create each element manually in plain JavaScript (without jQuery involved) and append it to the document (I didn't try this approach, by the documentation says it works.

     - Place the code responsible to inject those HTML element inside MSApp.execUnsafeLocalFunction();

    something like:

    MSApp.execUnsafeLocalFunction(function() {  $("#myDiv").append($element);   });

    Please check http://msdn.microsoft.com/en-us/library/windows/apps/hh767331.aspx for more info.

    Wednesday, September 26, 2012 6:01 PM