javascript - How can I be able to post one image and 'two textareas values to database simultaneously using AJAX and PHP? -
Revision in this script so that I can insert images and texts together (JSON) together. With the Jquery.form.js plugin, I want to insert both image and text values ... Let me know if there could be any other option to do this without using the jquery.form.js plugin. I am new to Ajax .. Now help me.
The image goes to ajaximage.php and the texts go to ajtest.php, when I upload the image and text together, the image is inserted, then the text is inserted, a two lines Uses (when Textarea and Image fields are not empty), first line is used for the image and second line for text fields, this is my problem, I want to insert images and texts in a line < / P>
Script: form :
& lt; Script type = "text / javascript" src = "script / jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "script / jquery.form.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ('# photoimg') Live ('change', function () {$ ("# preview"). Html (''); $ ("# preview") .html ('& lt; img src = "loader.gif" alt = "uploading ...." />); $ ("# imageform") .jaxform ({target:' #preview '} ) Submit. ();});}); & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ (". Submit_button"). Click (function () {var message = $ ('# content'). Val (); var textcontents = $ ("# source" ) .val (); $ .ajax ({type: "post", url: './ajtest.php', data: {tc: message, ts: text content}, cache: true,}}}})} };
Comments
Post a Comment