如何将ajaxform的目标输出值转换为函数

时间:2015-02-22 09:41:21

标签: javascript php jquery jquery-file-upload ajaxform

我有一个带有ajaxForm技术的文件上传器。 如何在函数中输出php文件而不是jqueryForm 输出&#39; ,用JS做一些事情?< / p>

e.g。我想从php文件中输出图像文件名

echo 'media/'.$NewFileName.'';

所以它会像:

  

媒体/ IMG_4321.jpg

这是我的上传者

jQuery(document).ready(function() { 
var options = { 
        target: 'output',   // target element(s) to be updated with server response     
        beforeSubmit:  beforeSubmit,  // pre-submit callback 
        success:       afterSuccess,  // post-submit callback 
        uploadProgress: OnProgress, //upload progress callback 
        resetForm: true        // reset the form after successful submit 
    }; 

 jQuery('#mediaForm').submit(function() { 
        jQuery(this).ajaxSubmit(options);           
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 

...

和php文件管理

    echo '<p style="color:#46A81E; font-family: light;">Success! File Uploaded.</p>';
    if($File_Ext=='.jpg' || $File_Ext=='.jpg' || $File_Ext=='.png' || $File_Ext=='.gif' )
    {
        //echo "<img src='media/".$NewFileName."' id='preview' class='img-responsive'>";
        echo 'media/'.$NewFileName.'';
    }
    if($File_Ext=='.mp3' ||$File_Ext=='.mpeg' || $File_Ext=='.wav')
    {
        echo '<audio controls id="preview">
                      <source src="media/'.$NewFileName.'" type="audio/mpeg">
                      <source src="media/'.$NewFileName.'" type="audio/mp3">
                      <source src="media/'.$NewFileName.'" type="audio/x-wav">
                      <source src="media/'.$NewFileName.'" type="audio/basic">
                    Your browser does not support the audio element.
                </audio>';
    }

...

0 个答案:

没有答案