Javascript working only on main site

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
teqel
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Apr 20, 2014 9:38 pm

Javascript working only on main site

Post by teqel » Sun Apr 20, 2014 9:50 pm

Hi all!

I have big problem. I wrote a simple javascript code to run php file:

Code: Select all

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="application/javascript">
function getData(str){
        $.ajax({
                type:'post',
                url:'ajax.php',
                data:{"sending":str},
                success: function(data){
                        document.getElementById("out").innerHTML = data;
                }
        });
}
getData('%')
</script type="application/javascript">
        <input type="text" id="textfield" onkeyup="getData(this.value)">
        <button onclick="getData(document.getElementById('textfield').value);">Click me!</button>
        <div id="out" style="max-height: 350px; overflow-y:scroll;"></div>
but this code working only on main page! When I try run it on subpage I have this error: "undefined is not a function"
I have joomla 3.2 based on T3 framework template and subpages have different layouts.

What I have to do to get this code working on subpages?

Pleas help!

Locked

Return to “General Questions/New to Joomla! 3.x”