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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:31:37+00:00 2026-05-13T07:31:37+00:00

Very simple Ajax request taking employee id and returning the user info as HTML

  • 0

Very simple Ajax request taking employee id and returning the user info as HTML dumb.


Request ajax("employee/info?emp_id=3543")


Response
id = 3543
name = some name

This is just another simple JS trick to populate the UI.

However i do not understand how something like below is equally able to execute correctly and dump the HTML code.

<script type="text/javascript" src="employee/info?emp_id=3543" />

When page encounters following code it executes like the ajax request is executed and dumps code into page. Only difference is its no more asynchronous as in case of Ajax.

Questions :

Is this correct approach ? its +ves and -ves.

Which are the correct scenarious to user it?

Is this also means that any HTML tag taking “src” tag can be used like this?

  • 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-13T07:31:37+00:00Added an answer on May 13, 2026 at 7:31 am

    I have used this kind of javascript loading for cross domain scripting. Where it is very useful. Here is an example to show what I mean.

    [Keep in mind, that JS does not allow cross domain calls from javascript; due to inbuilt security restrictions]

    On domain www.xyz.com there lies a service that give me a list of users which can be accessed from http://xyz.com/users/list?age=20
    It returns a json, with a wrapping method like following
    JSON:

    {username:"user1", age:21} 
    

    If I request this json wrapped in a method like as follows:

    callMyMethod({username:"user1", age:21})
    

    Then this is a wrapped json which if loads on my page; will try to invoke a method called callMyMethod. This would be allowed in a <script src="source"> kind of declaration but would not be allowed otherwise.

    So what I can do is as follows

    <script language="javascript" src="http://xyz.com/users/list?age=20"></script>
    <script language="javascript">
        function callMyMethod(data)
        {
          //so something with the passed json as data variable.
        }
    </script>
    

    This would allow me to stuff with JSON coming from other domain, which I wouldn’t have been able to do otherwise. So; you see how I could achieve a cross domain scripting which would have been a tough nut to crack otherwise.

    This is just one of the uses.

    Other reasons why someone would do that is:

    • To version their JS files with
      releases.
    • To uncache the js files so that they are loaded on client as soon as some changes happen to js and params being passed to URL will try to fetch the latest JS. This would enable new changes getting reflected on client immediatly.
    • When you want to generate conditional JS.

    The usage you have specified in example wouldn’t probably serve much purpose; would probably just delay the loading of page if processing by server takes time and instead a async ajax call would be much preferred.

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

Sidebar

Related Questions

I have a very simple ajax request: $.get(url, data) .done(function () { }) .fail(function
Below is a very simple AJAX request that works just fine until I put
My first and very simple AJAX request not outputting status 200 OK.. and instead
The following code is a very simple ajax call to server that alerts back
I have a very simple sinatra site that I'm trying to access via ajax
I have this very simple jQuery function: $(.milestone-in-tree).live({ mouseenter: function() { setTimeout( $.ajax({ type:
Very simple question. I need to perform a task when the user closes his
I'm sure this is very simple.We have an ajax call to a controller. The
I have a very simple javascript class that does an ajax call to a
I'm making very simple ajax requests like $.ajax({ type: POST, url: atuamae.org/send.php, data: dataString,

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.