Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:35:50+00:00 2026-06-09T05:35:50+00:00

I’m having a bit of an issue with RequireJS. I have a .NET site

  • 0

I’m having a bit of an issue with RequireJS.

I have a .NET site with several controls that contains JS code which requires parameters generated by .NET. I’ve been trying to implement RequireJS into my site, but I ran into a small problem.

I’ve included the script tag that references RequireJS at the top of the page, as well as reference to main.js within that script tag. Inside my main.js I have the following code;

require.config({
    paths: {
        'jquery' : '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min'
    }
});

Then I have a web control that is supposed to display a flash video. This web control contains the following piece of code;

require(['jquery'], function ($) {
    if (!eval('<%= FlashAvailable.ToString().ToLowerInvariant() %>')) {
        var url = '<%= FallbackImageUrl %>';
        if (!url) {
            $("#flashcontent").remove();
        }
        return;
    }

    var link = '<%= Page.ResolveUrl("~/Templates/AlloyTech/scripts/slideshow.swf") %>';
    var width = '<%= Width %>';
    var height = '<%= Height %>';

    var variables = { xml: '<%= ConfigXml %>' };
    var params = { wmode: 'transparent' };
    var attributes = { };

    swfobject.embedSWF(link, 'flashcontent', width, height, '10', false, variables, params, attributes);
});

This should be working fine right? However, executing the page results in two sets of errors.

 1. GET http://episerversite6/scripts/jquery.js 404 (Not Found)
 2. Uncaught Error: Script error http://requirejs.org/docs/errors.html#scripterror

Why is it trying to find jquery.js when I’ve defined the path for jquery is ‘http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min&#8217;. I’ve tried adding a second parameter for the path, which is a local fallback jQuery file, and that makes everything work, but I’d still get the first error in my console.

Secondly, why am I getting the scripterror message? I’ve checked my code several times and I can’t seem to find anything wrong with it. Does it have something to do with the code being executed before jQuery has time to load?

So I guess what I’m asking is, what’s the best way to use RequireJS with inline scripts? I hope someone can help. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:35:51+00:00Added an answer on June 9, 2026 at 5:35 am

    It seems I have misunderstood how RequireJS works and the need to rewrite my code accordingly.

    So what I decided to do instead is append all ASP.NET generated variables to the elements they’re affecting as data-* attributes, and moving all JavaScript codes to individual files which are then referenced in the main.js script that runs on page load. The data-* attribute values are fetched later when the script and its dependencies have been loaded.

    So here’s what I did to the project I mentioned in my initial question, which is actually an EPiServer CMS demo project called Alloytech.

    Flash.ascx

    <div id='flashcontent'  data-flash-available="<%= FlashAvailable.ToString(CultureInfo.InvariantCulture).ToLowerInvariant() %>"
                        data-fallback-image="<%= FallbackImageUrl %>"
                        data-flash-link="<%= Page.ResolveUrl("~/Templates/AlloyTech/scripts/slideshow.swf") %>"
                        data-flash-width="<%= Width %>"
                        data-flash-height="<%= Height %>"
                        data-flash-variables="<%= ConfigXml %>">
        <img src='<%= FallbackImageUrl %>' alt='<%= FallbackImageAlt %>' />
    </div>
    

    main.js

    require.config({
        shim: {
            'swfobject' : {
                exports: 'swfobject'
            }
        },
    
        paths: {
            'jquery': ['http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min', '/Scripts/jquery-1.7.2.min'],
            'alloytech': '/templates/alloytech/scripts/alloytech',
            'mobile': '/templates/alloytech/scripts/mobile/mobile',
            'swfobject': '/Templates/AlloyTech/scripts/swfobject'
        }
    });
    
    define(['jquery', 'alloytech', 'mobile', 'swfobject'], function ($, A, M, swfobject) {
        $.fn.addFlash = function () {
            return this.each(function () {
                var el = $(this);
                var flashAvailable = el.data('flash-available'),
                    fallbackImage = el.data('fallback-image'),
                    flashLink = el.data('flash-link'),
                    flashWidth = el.data('flash-width'),
                    flashHeight = el.data('flash-height'),
                    flashVariables = el.data('flash-variables');
    
                if (!eval(flashAvailable)) {
                    var url = fallbackImage;
                    if (!url) {
                        el.remove();
                    }
    
                    return;
                }
    
                var link = flashLink;
                var width = flashWidth;
                var height = flashHeight;
    
                var variables = { xml: flashVariables };
                var params = { wmode: 'transparent' };
                var attributes = {};
    
                swfobject.embedSWF(link, 'flashcontent', width, height, '10', false, variables, params, attributes);
            });
        };
    
        $(function () {
            $("#flashcontent").addFlash();
        });
    });
    

    I hope someone else will find this useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.