Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Location
    Tampa
    Posts
    223
    Thanks
    23
    Thanked 0 Times in 0 Posts

    AJAX PHP Post using image submit button

    I am trying to follow this article on doing a POST request with AJAX and PHP and it works fine, but as soon as I switch from the default submit button to an image I get an error. I would really appreciate any assistance on why switching the submit button to an image would affect it.

    Thanks

    http://www.hiteshagrawal.com/ajax/form-post-in-php-using-ajax/comment-page-1

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts
    Quote Originally Posted by dprichard View Post
    I would really appreciate any assistance on why switching the submit button to an image would affect it.

    Thanks
    Because you have made a mistake in your code,
    possibly a typo.

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Location
    Tampa
    Posts
    223
    Thanks
    23
    Thanked 0 Times in 0 Posts
    I must say your comment wasn't very helpful but thanks for trying.

    The code works with this for the submit button.

    Code:
    <input type="button" value="Submit" onclick="ajaxFunction();" />
    But not this

    Code:
    <input type="image" src="images/btn-submit.png" onclick="ajaxFunction();" />

  • #4
    Regular Coder
    Join Date
    Jul 2004
    Location
    Tampa
    Posts
    223
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Okay, finally figured out the answer. The onclick doesn't work on the submit image. I changed it to a regular image instead of input type="image" and it works now.

  • #5
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts
    Quote Originally Posted by dprichard View Post
    Okay, finally figured out the answer. The onclick doesn't work on the submit image. I changed it to a regular image instead of input type="image" and it works now.
    Ah ha , I was helpful by correctly pointing out
    the fact that you had a mistake in your code.


  •  

    Posting Permissions

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