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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:39:08+00:00 2026-05-16T18:39:08+00:00

I have been developing and testing with inline jQuery. I am using CodeIgniter and

  • 0

I have been developing and testing with inline jQuery. I am using CodeIgniter and the below refers to my views.

I have <script="text/javascript">JQUERY CODE</script> at the top of my page. Some of my code is dynamic in that it uses PHP vars, e.g. when making an Ajax call, the URL is preceeded by <?php echo base_url(); ?>.

I have gotten the code working, but I want to put it in an external JS file for cleanliness. There seems to be no way I can think of to do this. Am I correct?

One aspect of my site is Google Maps. I use them all over the place. Again, parts of the code are dynamic, from PHP. Same question.

As a slight change, with the maps, I have many pages with many slightly different maps on them. Is there anyway to efficiently reuse map code, or am I going to have to have some duplicate code?

  • 1 1 Answer
  • 1 View
  • 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-16T18:39:08+00:00Added an answer on May 16, 2026 at 6:39 pm

    So are your customizations mostly just parameter replacements for things like google maps? If so, why not just have a function call that take a JSON object as a parameter. Have your backend serve some JSON data via an AJAX request, pass the data to the function, and you’re done. Less JS code to download, and a much cleaner setup.

    // site.js
    function displayMap(params) {
      // code to display google map using values from params
      // for instance:
      var lat = params.lat;
      var long = params.long;
    }  
    

    To use this, do something like this:

    $.get('ajax/mapdata.json?id=5', function(data) {
      displayMap(data);
      alert('Load was performed.');
    });
    

    Output JSON from your app by creating something like this:

    {
      lat: 232
      long: 123
    }
    

    Hope that helps!

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

Sidebar

Related Questions

I have been developing an Android application and testing the orientation sensor using SensorSimulator
I have been developing a very simple text game using Objective C and Xcode.
We have been developing code using loose coupling and dependency injection. A lot of
I have been developing the application for drawing, and there is the code: public
I have been developing the application for drawing, and there is the following code
I have been developing an Android app and testing with a 1.5 AVD and
I have been developing a new JavaScript application which is rapidly growing in size.
I have been developing a Java application using J2EE and a Derby database. My
I have been developing a game using Flex, and used the Timer class to
I have been developing and testing the ThreeSharp library on a 32bit Vista machine

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.