开发者

Run PHP when Input is changed

I was wondering if there was a way of running PHP when an input is changed, the input is question is:

<input id="custom_file_upload" type="file" name="Filedata" />

I was thinki开发者_如何学JAVAng prehaps using some jQuery or AJAX to run an external file when changed?

Any help would be appreciated,

Thanks!


http://api.jquery.com/change/

mixed with

http://api.jquery.com/jQuery.post/

Great example of this idea can be seen in some examples here: http://jquery.bassistance.de/validate/demo/

Usernames and emails are validated against a script, to make sure they do not already exist in the DB.


You're right, AJAX will be the way to go. Using jQuery, you can do something like this:

$("#custom_file_upload").change(function() {
    $.post("someScript.php", function(data) {
        //Done!
    });
});

This binds an event handler function to the change event of the element, and uses the post method to fire an asynchronous request to "someScript.php".

There are various jQuery AJAX methods available to you. The right one to choose will depend on what exactly you want to achieve.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜