$ ("#duty_add"). Click (function () {var root = $ ("P#root"). Text (); var vals = $.trim ($ ("#content"). Val ()); if (vals! = ") {$.ajax ({type:" POST ", Url:root +"/duty/dutyadd ", Data: {' content ': Vals}, Success:function (data) {Console.log (file_value); $ ("#result"). HTML (data); } }); }else{alert (' content cannot be null '); } }); $ ("#upload_file"). Change (function () {if ($ ("#upload_file"). val ()! = ") {var root = $ (" P#root "). Text (); Gets the path var Root2 = $ ("P#root2"). Text (); Get path var formData = new FormData ($ ("#uploadForm") [0]); $.ajax ({url:root + "/duty/fileup", type: ' POST ', Data:formdata, Async:true, Cache:false, Contenttype:false, PROcessdata:false, Success:function (returndata) {File_value[returndata.name] = RET Urndata.url; $ ("#uploadForm"). Prepend (' + returndata.name + ' + ')
"); } }); }; });
An attachment upload is an AJAX asynchronous commit that generates a hyperlink from each other.
$("#uploadForm").prepend(''+ returndata.name + ''+"
");
But when textarea click Submit, then how to submit the content of the hyperlink?
If it is more than one upload file, how to submit the value of the upload file function return? How to get more convenient, is not my train of thought is wrong?
Think for a long time can't figure out how to deal with such?
Give me a clue, I want to try it.
Reply content:
$ ("#duty_add"). Click (function () {var root = $ ("P#root"). Text (); var vals = $.trim ($ ("#content"). Val ()); if (vals! = ") {$.ajax ({type:" POST ", Url:root +"/duty/dutyadd ", Data: {' content ': Vals}, Success:function (data) {Console.log (file_value); $ ("#result"). HTML (data); } }); }else{alert (' content cannot be null '); } }); $ ("#upload_file"). Change (function () {if ($ ("#upload_file"). val ()! = ") {var root = $ (" P#root "). Text (); Gets the path var Root2 = $ ("P#root2"). Text (); Get path var formData = new FormData ($ ("#uploadForm") [0]); $.ajax ({url:root + "/duty/fileup", type: ' POST ', Data:formdata, Async:true, Cache:false, Contenttype:false, PROcessdata:false, Success:function (returndata) {File_value[returndata.name] = RET Urndata.url; $ ("#uploadForm"). Prepend (' + returndata.name + ' + ')
"); } }); }; });
An attachment upload is an AJAX asynchronous commit that generates a hyperlink from each other.
$("#uploadForm").prepend(''+ returndata.name + ''+"
");
But when textarea click Submit, then how to submit the content of the hyperlink?
If it is more than one upload file, how to submit the value of the upload file function return? How to get more convenient, is not my train of thought is wrong?
Think for a long time can't figure out how to deal with such?
Give me a clue, I want to try it.
You have saved the uploaded results in this variable when the file was uploaded. file_value
Then in your submission textarea
, in data :{'content':vals},
this place, you file_value
can also pass it to the backstage.
Like what:data:{'content':vals, 'files':file_value},
You send the code, there is no file_value
place for this variable definition, so here is the assumption that your two at the time of the ajax
trigger, you can access the variable, and the same one.
If the content is to be submitted, it should be placed in input