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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:52:00+00:00 2026-06-08T14:52:00+00:00

I’m having difficulty figuring out where I put my Ajax and server code in

  • 0

I’m having difficulty figuring out where I put my Ajax and server code in a Joomla component. I’ve created a simple hello world component following the Joomla part 2 docs (I don’t need any of the other stuff just a simple component).

Now I’m trying to add Ajax code with jquery using a simple jquery/ajax tutorial. So I added this code to:

components/com_mycomponent/views/mycomponent/tmpl/default.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
<html>
<head>
  <title>Ajax with jQuery Example</title>

<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/JavaScript">
  $(document).ready(function(){
    $("#generate").click(function(){
      $("#quote p").load("script.php");
    });
  });
  </script>
<style type="text/css">
    #wrapper {
      width: 240px;
      height: 80px;
      margin: auto;
      padding: 10px;
      margin-top: 10px;
      border: 1px solid black;
      text-align: center;
    }
  </style>
</head>
<body>
  <div id="wrapper">
    <div id="quote"><p> </p></div>
    <input type="submit" id="generate" value="Generate!">
  </div>
</body>
</html>

In the same directory I added the script.php file for the server side processing. Again, just from the tutorial:

<?php  
header("Cache-Control: no-cache");  
// Ideally, you'd put these in a text file or a database.    
// Put an entry on each line of 'a.txt' and use $prefixes = file("a.txt");  
// You can do the same with a separate file for $suffixes.  
$prefixes = array('Mashup','2.0','Tagging','Folksonomy');  
$suffixes = array('Web','Push','Media','GUI');  
// This selects a random element of each array on the fly  
echo $prefixes[rand(0,count($prefixes)-1)] . " is the new "    
   . $suffixes[rand(0,count($prefixes)-1)];  
// Example output: Tagging is the new Media  
?> 

I’m guessing the way I specify script.php is not right because I get the generate button when I access the component:

http://mysite.com/index.php?option=com_mycomponent

EDIT: Didn’t notice the error which is pretty crucial. I get a Not Found error: http://mysite.com/script.php. Which is obviously not there. Where do I put this for my component? Keeping in mind that the whole point of creating a component with ajax is so that I can have the joomla framework available in script.php. For example doing calls such as: $user =& JFactory::getUser();

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-08T14:52:03+00:00Added an answer on June 8, 2026 at 2:52 pm

    try using

    components/com_mycomponent/views/mycomponent/tmpl/script.php in load function

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.