Results 1 to 2 of 2

Thread: getting data sent with ajax that was not sent from a form

  1. #1
    Join Date
    May 2013

    getting data sent with ajax that was not sent from a form

    So I need to be able to use the data that was sent with ajax to a PHP page and create an image tag with it as the src value.

    The thing is that data is not being sent as a result of an input field or form submission. Here is the jquery I'm using the grab the data I need and send it...

    		var $itemUrl = $(this).parents('.item').attr('data-url');
                    type: 'POST',
                    url: 'whiteboard.php', 
                    data: 'val=' + $itemUrl, 
                    success: function(data, textStatus, jqXHR) {
                            window.location = 'whiteboard.php';
                    error: function(jqXHR, textStatus, errorThrown) {
                            alert("Oh crap! Threw and error again!");
            return false;
    And here is the PHP I'm trying to use to do something with it...

    PHP Code:
    "I got your value! $value";
    However I'm getting an error that says that the value 'val' is not defined, I was messing with some other code examples trying to get the effect that I need. So maybe I did this wrong.

  2. #2
    Join Date
    Oct 2012

    data : { "val" : itemUrl },

    i.e. pass data into the AJAX call as a JSON object not a URL parameter

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center