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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:43:51+00:00 2026-05-26T07:43:51+00:00

I have simple question – why my *.png picture, created by PHP GD, is

  • 0

I have simple question – why my *.png picture, created by PHP GD, is not displayed properly on the web page?
My PHP code is:

back.php

    <?php
    $height = 200;
    $width = 600;
    $jVar = $_POST['jPacket']; //velue from jQuery script

    $im = imagecreatetruecolor($width, $height);
    $white = imagecolorallocate($im, 255, 255, 255);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefill($im, 0, 0, $white);
//line_1
    imageline($im, 10, 0, 10, $height, $black);
//line_2
    imageline($im, $jVar, ($height/2), $height-$jVar, ($height/2), $black);

    header('Content-type: image/png');
    imagepng($im);
    imagedestroy($im);
?>

…and simple jQuery AJAX post is here:

script.js

var graphBack = $('<img id="backGraph" src="back.php" alt="backGraph"/>');

$('.value').keyup(function() {
      $.post(
          "back.php", //send the POST here
      {
           jPacket: $('.value').val() //value from <input>
      }, function() {
           $('#backGraph').remove(); //remove old picture
           graphBack.insertAfter($('#sipGraph p')); //put the picture here
      });

The picture is displayed properly but not everything is visible. The ‘line_1’ is visible because all elements in imageline(...) are static but the ‘line_2’ is not displayed because 'imageline(..., $jVar, ...) has value that is send by $_POST['jPacket'] from scipt.js.
Do I properly show the IMG in graphBack.insertAfter($('#sipGraph p'));?

When I perform above scanario but data is sent not from jQuery but ordinary HTML FORM everything is ok…

  • 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-26T07:43:52+00:00Added an answer on May 26, 2026 at 7:43 am

    The post you are sending is not what is being shown on the page. When you attach var graphBack = $('<img id="backGraph" src="back.php" alt="backGraph"/>'); to the page, you are creating a second, separate request with no post – essentially loading an image on the page. Back is being called twice essentially, and the time with POST is not the response that you are displaying.

    I would instead simply attach a generated image tag along the lines of $('<img id="backGraph" src="back.php?jPacket='+ MYAWESOMEJPACKET +'" alt="backGraph"/>'); and replace the current one – further updating the script to use GET.

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

Sidebar

Related Questions

I have a simple question: Why the program below does not write the whole
I have simple question about .net garbage collection. In the following code I create
I have a simple question yet it's not working out. See this html: <div
I have very simple question but the answer is still not clear. If i
I have a simple question about passing custom objects via a webservice. I created
I have probably simple question: /the code: http://jsfiddle.net/FZufj/8/ / I have a simple code
I have a simple question related to viewport.. I have a page which has
i have a simple question, i need to convert back the dateformat in coldfusion,
I have a simple question regarding PHP Classes. Multiple times I have seen other
I have a simple question. Is there a way ( using reflections I suppose

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.