jquery - $('#fileupload').fileupload function is not calling -
i configuring blueimp upload image on click post button. problem is not calling $('#fileupload').fileupload
function. have included next javascript files. next code please see problem.
<head> <script type="text/javascript" src="../../js/jquery.min.js"></script> <script type="text/javascript" src="../../js/jquery-ui.js"></script> <script type="text/javascript" src="../../js/jquery-file-upload-master/js/jquery.fileupload.js"></script> <script type="text/javascript" src="../../js/jquery-file-upload-master/js/vendor/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../js/jquery-file-upload-master/js/jquery.iframe-transport.js"></script> <script type="text/javascript"> $('#fileupload').fileupload({ datatype : 'json', url : "ownmessages", add: function (e, data) { $('#post') .click(function () { $('#post').text('uploading...'); data.submit(); }); }, done: function (e, data) { $('#post').text('upload finished.'); } }); </script> </head> <body> <s:form action="ownmessages" enctype="multipart/form-data" method="post"> <s:textarea rows="2" cols="40" name="message" id="message1"></s:textarea><br> <s:select name="msg_visibility" id="msg_visibility" list="#{'public':'public', 'friends':'friends','me':'me only'}" value="public"/> <input id="fileupload" type="file" name="user_post_image[]" data-url="ownmessages"/> <input type="button" value="post" id="post" /> </s:form> </body>
you need wait document finish loading before seek , select elements. jquery .ready()
method waits document object model (dom) finish loading , runs script.
$(document).ready(function() { $('#fileupload').fileupload({ datatype : 'json', url : "ownmessages", add: function (e, data) { $('#post') .click(function () { $('#post').text('uploading...'); data.submit(); }); }, done: function (e, data) { $('#post').text('upload finished.'); } }); });
instead of using .ready()
can pass function jquery.
$(function() { // run after dom loaded });
jquery blueimp
No comments:
Post a Comment