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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:22:53+00:00 2026-06-07T23:22:53+00:00

Scenario A page invokes a remote script available at this url: http://url.to.script/myScript?ScriptParamsList . Let’s

  • 0

Scenario

A page invokes a remote script available at this url: http://url.to.script/myScript?ScriptParamsList. Let’s assume that:

  • Async execution is not required.
  • Displaying output is not required.
  • The script is called on a button click event. Let Handler() be the javascript event handler:


    function Handler()
    {
    //invoke the remote script
    }

Several methods are available to implement Handler() function:

  • script vs img tag:

document.write('<script src="http://url.to.script/myScript?ScriptParamsList" type="text/javascript"></script>');

document.write('<img src="http://url.to.script/myScript?ScriptParamsList" />');

  • jQuery .html() vs .load():

$('#TargetDiv').html('<img src="http://url.to.script/myScript?ScriptParamsList" />');

$('#TargetDiv').load('http://url.to.script/myScript?ScriptParamsList');

Question

Which are the advantages and the disadvantages?

  • 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-07T23:22:55+00:00Added an answer on June 7, 2026 at 11:22 pm
    • document.write will replace your current document when it’s called after the document is loaded. Never use this method.
    • Using <script> allows you to fetch a request from an external domain, without being hindered by the same origin policy. Additionally, in the server’s response, you can add and execute JavaScript, which might be useful.
    • Using .html('<img ...>') makes no sense, unless your server returns an image with meaningful data. If you intend to only trigger a server request, the following would be better:

      new Image().src = 'http://url.to.script/myScript?...';
      
    • $('..').load is not going to work if the URL is located at a different domain, because of the same origin policy.

    I vote for the new Image().src = '..'; method. If you dislike this syntax, and want more jQuery, use:

    $('<img>').attr('src', 'http://...');
    

    Note: The result may be cached. If you don’t want this to happen, append a random query string, to break the cache (eg. url = url + '&_t=' + new Date().getTime()).

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

Sidebar

Related Questions

Scenario The web server gets a request for http://domain.com/folder/page . The Accept-Language header tells
Imagine the scenario you have a listing page that is a concatenation of multiple
The Scenario Using jQuery, I have a page that has a popup overlay containing
Here is my scenario. User fills out this large page which is dynamically created
i have master-content page scenario.I have a link button on content page. that redirects
Well I would reproduce in a html page this scenario. I have a div
Scenario: I have a Javascript-generated web page that someone else wrote a long time
Here's the scenario: Page 1 has a text box that, if filled, will be
This is a little weird. I have the following scenario: A page containing a
My scenario is this: When the page is loaded, a listbox with countries is

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.