POST a form with Jquery AJAX When input is a File

后端 未结 2 875
你的背包
你的背包 2021-02-09 06:21

I have several areas where I use AJAX to submit text fields.

 var name = $(\"input#name\").val(); 

   $.ajax({  
      type: \"POST\",  
      url: \"bin/proces         


        
相关标签:
2条回答
  • 2021-02-09 06:30

    By default, jQuery cannot POST a form via AJAX if it contains a upload field.

    You can try this plugin: http://jquery.malsup.com/form/

    0 讨论(0)
  • 2021-02-09 06:50

    This is typically done using an iFrame to send the file to the server.

    The jQuery Form Plugin is a great resource for that.

    Here is another upload script which uses xhr when possible (FF, Safari) and falls back gracefully to iFrame if necessary (IE)

    0 讨论(0)
提交回复
热议问题