0

In my php file the javascript/html code is written using echo. I would like to access the image that is going to be placed in "place1" div in javascript and pass it to php.

here is my code:

 // create a placeholder for an image- user is going to drag and drop an image here
echo "<div id= 'place1' class = 'place'></div>";
echo '<button id="apply" name="save" type="submit">Apply Changes</button>';
echo '<script src="http://code.jquery.com/jquery-1.9.1.js"></script>';
//javascipt code to find the source of that image
echo 
'<script>
    $(document).ready(function(){
        $("#apply").click(function() {
            var frame = $("#place1").children("img").attr("src");
            $.ajax({
                url: "thumbnails.php",
                type: "POST",
                data: frame
            });
        });
    });
</script>';

 // access frame variable (image source) in php ??? not sure how to do this part..
$frame = $_post['frame'];
1
  • What is the value of var frame (in the jQuery section) Commented Mar 26, 2013 at 22:02

1 Answer 1

0

in your jquery you must use a key/value pair when sending data:

key=value

With that in mind, for your data that you are sending, your are using the variable frame, but frame does not have the key/value pair. It should be:

var frame = "frame="+$("#place1").children("img").attr("src");

This will now allow you to capture the variable in PHP:

$frame = $_POST['frame']

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.