Showing Response Status using JQuery

Showing Response Status using JQuery

What I'm trying to do is download some image from a URL then upload it to WordPress post, my form below:

<form method="post" id="upload"> <?php foreach($data as $row): ?> <label>URL</label> <input type="text" id="url_<?php echo $row->id;?>" name="data[<?php echo $row->id;?>][url]" value="<?php echo $url;?>" />
<?php endforeach;?> <button name="act" value="savepost">Save</button> </form> <!-- showing result here --> <div id="result"></div>
So, then when click Save button... the action will call function prc_upload()
function prc_upload() { $posts = $_POST['data']; foreach ($posts as $post) { $filename = $post['filename']; $title = $post['title']; // Process uplaoding here if (!$fileSaved) { $result = $filename.' Can not saved !!'; } else { $result = filename' Saved Succesfuly!!'; } } How to use jquery to show response result "$result" one by one when Save button clicked..