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

  • Home
  • SEARCH
  • 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 3306008
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:14:15+00:00 2026-05-17T21:14:15+00:00

I don’t know where I got the idea before but a year ago I

  • 0

I don’t know where I got the idea before but a year ago I wrote this in php:

<script type="text/javascript" src="http://www.mydomain.com/getmarkers.php"></script> 

Now I’m ready to convert this website to an ASP.NET MVC website and I’m wondering what the best way is to convert this into something more ‘normal?’.

The options I could think about where:

  1. Custom HttpHandler for .js files
  2. Keep using the script tag but with a custom route to an action
  3. Modify the javascript to load the serverside data using an ajax call

What the getmarkers.php currently does is generate javascript to add markers to a google map. The benefit of referencing the php inside the script tag is that

  1. It’s never cached, the markers are always up to date (I know there are alternatives)
  2. It keeps my html clear of any javascript
  3. Very easy to add/remove certain fields for the generated markers

An example of what is being generated :

infoWindows[0] = new google.maps.InfoWindow({
    content: '<div style="width:250px;color:#000;">...html content for this specific marker...</div>'
});

google.maps.event.addListener(markers[0], 'click', function() {
    infoWindows[0].open(map, markers[0]);
});

What changes is the index (0 in this example) and the content of the html.

Question
1. What solution do you think fits best
2. Is it bad to reference a script by calling a serverside ‘file’.

  • 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-17T21:14:15+00:00Added an answer on May 17, 2026 at 9:14 pm

    I can see no downside to embedding server-generated .js files. I personally would choose the “custom route” option so it’s clear it’s a generated file, leaving the .js extension to static resources.

    However, serving the markers in a pure data format like JSON, and loading them using Ajax would have the advantages that

    • you have the data in a neutral “meta format” that you can re-use elsewhere without having to build a new data source

    • you can keep the Loading / HTML generating process in one place, the parent page or one of its static scripts, instead of controlling the way the HTML looks in the server-side script

    • the amount of transferred data is probably reduced

    • It’s cleaner overall

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

Sidebar

Related Questions

I don't know if anyone has seen this issue before but I'm just stumped.
I don't know if i am doing it right, this is what I got:
I don't want PHP errors to display /html, but I want them to display
I don't expect a straightforward silver bullet answer to this, but what are the
Don't need to do this right now but thinking about the future... What would
I don't know if thats right but for some reason my stored procedure is
I don't know if this is possible. I display a table of results and
I don't think this should be in my view, but instead handled by the
I don't know when to add to a dataset a tableadapter or a query
I don't understand where the extra bits are coming from in this article about

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.