• Blogs (9)
    • 📱 236 - 992 - 3846

      đź“§ jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • JavaScript: dynamic script calling

    Blogs20122012-09-14


    JavaScript: dynamic script calling

    I need to call an existing javascript with different input parameter in ajax way. The following is my solution:

     var t1='variable_from_search_input_field';
     var t2='http://williamjxj.com/exist.js?test_variable=';
     var t3='&tn=news1&from=news2&cl=2&rn=10&ct=0';
     var search_dynamica_variable = t2 + t1 + t3;
     document.write('');
    </script>

    By the way, the following ways not work:

    $(window).load(function() {
     $.getScript(search_dynamica_variable);
     $.ajax(search_dynamica_variable);
    });

    Here is a helpful article in details:

    http://unixpapa.com/js/dyna.html