...

View Full Version : AJAX PHP Post using image submit button



dprichard
09-02-2010, 08:42 PM
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 (http://www.hiteshagrawal.com/ajax/form-post-in-php-using-ajax/comment-page-1#comment-27721)

DaveyErwin
09-02-2010, 08:49 PM
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.

dprichard
09-02-2010, 09:03 PM
I must say your comment wasn't very helpful but thanks for trying.

The code works with this for the submit button.


<input type="button" value="Submit" onclick="ajaxFunction();" />

But not this


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

dprichard
09-02-2010, 09:33 PM
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.

DaveyErwin
09-02-2010, 09:42 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum