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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:55:13+00:00 2026-06-11T20:55:13+00:00

I am developing mobile applications, and I was thinking, if I need to download

  • 0

I am developing mobile applications, and I was thinking, if I need to download a picture from a server, I cannot actually run the PHP natively (I am using a PhoneGap type setup), so how could I download a picture from a database, run it though JavaScript and then display it to the user?

I would imagine something like:

  1. Ajax request,
  2. Return HTML string of binary data
  3. Do some stuff to that?

Or

  1. Ajax request,
  2. Return a HTML string of reference to the picture, for example: picture1.jpg.
    In JavaScript, write something like document.write <img src="http://blahh/img/"+imagePath

I’m not sure what the best way to do this is.

  • 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-11T20:55:14+00:00Added an answer on June 11, 2026 at 8:55 pm

    To my mind, the simplest way to dynamically load external pictures is to get a JSON object from a PHP script containing the picture URL (like http://www.example.com/pictures/getPicture/YOUR_PICTURE_ID).

    Server side

    <?php
        $pictureUrl = 'http://example.com/pictures/picture.jpg'; //You can get it with a database query
        $pictureName = 'Foo';
        $pictureAltText = 'Bar';
    
        // You can do some stuff here.
    
        // At the end of the script, write result.
        echo json_encode(compact('pictureUrl', 'pictureName', 'pictureAltText'));
    ?>
    

    Client side

    <script type="text/javascript">
        // With jQuery
        $.getJSON('http://www.example.com/pictures/getPicture/YOUR_PICTURE_ID', function(data){
            console.log(data.pictureUrl, data.pictureName, pictureAltText);
    
            var img = new Image();
            img.src = data.pictureUrl;
            img.setAttribute('alt', data.pictureAltText);
    
            img.onload = function(){
                // Displaying picture when download completed
                $(img).appendTo('body');
            }
        });
    </script>
    

    If you don’t use jQuery, you have to use XMLHttpRequest to get the JSON encoded response and to parse it (you can see the MDN documentation at https://developer.mozilla.org/en-US/docs/JSON).

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

Sidebar

Related Questions

I will be developing some applications using mobile barcode scanners and need to choose
I'm developing a mobile web applications using jquery mobile, HTML 5. From this application
I want to look into developing mobile applications using HTML5. I'm very new to
We are developing wireless ad hoc communication applications on windows mobile 6 devices using
I recently started developing mobile applications using Flex 4.5. I try to migrate an
Can anyone give a comparative information between developing Android mobile applications using Eclipse SDK
can anybody suggest a framework for developing mobile applications using html5 ? I want
I was developing Windows Mobile applications on a Windows machine using C#, just to
I'm working with C#.net developing applications for windows mobile 6, and i need get
I recently started developing mobile applications using Flex 4.5 with the help of a

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.