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 6550243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:11:33+00:00 2026-05-25T12:11:33+00:00

As part of an ajax call I want to add this javascript function listed

  • 0

As part of an ajax call I want to add this javascript function listed between a script tag to my document. The ajax call works fine except it cuts out this portion of my document.

<script language="javascript"> 

    window.onload = function(){


            var input = document.getElementById('tid-acc');


            document.getElementById('rule-type').onchange = function() { 
               var v

al = this.value; 
           if (val == 'tid and acc') {
               input.style.display = 'inline'; 
           }
           else {
              input.style.display = 'none';
           }
        };
    }
    </script>

What am I doing wrong? For reason I won’t go into, I need to execute this function dynamically on Ajax call. 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-05-25T12:11:34+00:00Added an answer on May 25, 2026 at 12:11 pm

    Here is a good article about it: Global eval. What are the options?

    Article also compares how famous js libraries do it:

    Global eval in libraries

    So what do some of the popular Javascript libraries do? Which global
    eval solution do they chose?

    As we’ve seen earlier, jQuery sacrifices return value for a more
    extensive browser support, using script insertion technique in its
    jQuery.globalEval method.

    Prototype.js doesn’t even try to evaluate scripts globally — it uses a
    good old, direct eval invocation. Instead, Prototype.js warns about
    ramification of local execution in the documentation.

    Dojo choses the infamous window.eval variation, but does something
    really messed up — it uses indirect eval if eval exists on a global
    object (which should be true in all ES3-compliant browsers), and falls
    back on regular eval invocation. This kind of fall back obviously
    results in code executed locally, which should also happen silently.
    Dojo’s eval behavior will vary wildly depending on the environment,
    and has a possibility of uncaught error. On a related, humorous note,
    I was just as stunned by comments around dojo.eval as David Mark in
    this message.

    Mootools uses window.execScript when present, falling back on script
    insertion (similar to jQuery). jQuery’s script insertion, however, is
    more robust than Mootools, as they actually test if it results in
    evaluation of code.

    Fuse.js choses a very elaborate and careful strategy. It tests if
    indirect eval works as expected (catching an error if any), uses it if
    it does; if indirect eval is defunct, Fuse falls back on script
    injection. Unlike jQuery or Mootools, it actually tries to return a
    value of a code executed via script injection. It does so by wrapping
    contents of code with eval. An interesting side effect of executing
    code globally via eval is that function and variable declarations
    create deletable bindings (which is most likely an insignificant
    detail).

    Here is how Mootools 1.3.2 does it:

    String.implement('stripScripts', function(exec){
        var scripts = '';
        var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(all, code){
            scripts += code + '\n';
            return '';
        });
        if (exec === true) Browser.exec(scripts);
        else if (typeOf(exec) == 'function') exec(scripts, text);
        return text;
    });
    
    Browser.exec = function(text){
        if (!text) return text;
        if (window.execScript){
            window.execScript(text);
        } else {
            var script = document.createElement('script');
            script.setAttribute('type', 'text/javascript');
            script.text = text;
            document.head.appendChild(script);
            document.head.removeChild(script);
        }
        return text;
    };
    
    // on successful HTML request
    success: function(text){
        response.html = text.stripScripts(function(script){
            response.javascript = script;
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this xml as part of the responseXml of an Ajax call: <banner-ad>
I have this function that puts some data with Ajax call in a php
I want to make an AJAX call to an HTML-returning page, extract part of
Here's my javascript: <script type=text/javascript> var timer; $(document).ready(function () { timer = setInterval(updatetimerdisplay, 1000);
I want to make an AJAX call to my Java webapp. The Java webapp
I have a simple ajax call like this: $.ajax({ url: u, type: POST, dataType:
scenario: I want to do an ajax call to update the image shown. Example:
I have some jQuery with an Ajax call that looks like this: $.ajax({ type:
I have an ajax function in home.php that give me back this html response
I'm prepending the markup returned after an jquery ajax() call [the success part of

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.