Book Image

Moodle JavaScript Cookbook

Book Image

Moodle JavaScript Cookbook

Overview of this book

Moodle is the best e-learning solution on the block and is revolutionizing courses on the Web. Using JavaScript in Moodle is very useful to administrators and dynamic developers as it uses built-in libraries to provide the modern and dynamic experience that is expected by web users today.The Moodle JavaScript Cookbook will take you through the basics of combining Moodle with JavaScript and its various libraries and explain how JavaScript can be used along with Moodle. It will explain how to integrate Yahoo! User Interface Library (YUI) with Moodle. YUI will be the main focus of the book, and is the key to implementing modern, dynamic feature-rich interfaces to help your users get a more satisfying and productive Moodle experience. It will enable you to add effects, make forms more responsive, use AJAX and animation, all to create a richer user experience. You will be able to work through a range of YUI features, such as pulling in and displaying information from other websites, enhancing existing UI elements to make users' lives easier, and even how to add animation to your pages for a nice finishing touch.
Table of Contents (15 chapters)
Moodle JavaScript Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Using IO's alternative transport method for requesting external URIs


In this recipe, we will look at a method for retrieving data from an external domain. Due to security restrictions, it is not possible to make requests to an external URI with JavaScript's XMLHttpRequest. YUI avoids this restriction by including a built-in alternative transport mechanism based on Adobe Flash. In this way, any trusted domain with a valid cross-domain policy file may be used as a source of data.

Getting ready

First, we need to ensure that the remote domain is configured to accept incoming client requests. This is done by installing a cross-domain policy file crossdomain.xml on the remote domain. This cross-domain policy file specifies which domains are authorized to make requests via Adobe Flash (.swf) applications.

The following example configures the domain remote.example.com to accept incoming HTTP requests from any host on example.com.

Contents of the http://remote.example.com/crossdomain.xml file are as...