If the same code is uploaded under www.a.com normally at www. B .com and the same code is obtained through www.a.com, the error message "error: & quot;" is returned when the token is uploaded; in tokennotspecifieduptoken_func, after the uptoken returns a null value, it is assigned a value for the data called back by ajax. Therefore, upload the data... same code
Normal Upload at www.a.com
Under www. B .com, if the same code is obtained through www.a.com, the error message "token not specified" is returned.
In uptoken_func, after the uptoken returns a null value, it is assigned a value for the data called back by ajax. Therefore, the token is empty during upload.
Var qiniu_up = qiniu. uploader ({runtimes: 'html5, flash, html4', browse_button: 'qiniu _ browse', get_new_uptoken: true, unique_names: false, save_key: true, domain :'
', Container: 'container', max_file_size: '4mb', flash_swf_url :'
', Silverlight_xap_url :'
', Max_retries: 1, dragdrop: false, drop_element: 'container', chunk_size: '4mb', auto_start: false,/* automatic Upload not enabled */multi_selection: false, /* set to select only one file */filters: {mime_types: [{title: 'image files', extensions: 'jpg, jpeg, gif, png, bmp '}, {title: 'Voice files', extensions: 'MP3, wav '}]}, init :{}, uptoken_func: function (file) {var uptoken = ''; var media_info = '[{"directory": "1", "directory_class": "", "up_file_name": "' + file. name + '"," media_type ":" 1 "}]'; $. ajax ({type: "post", async: false,/* must use synchronization */url :'
', Data: {app_version:' 1. 0', app_target: 3, sdk_version: '1. 0 ', plat: 'other', media_info: media_info}, dataType: "jsonp", jsonp: "jsonpCallback", success: function (data) {if (data. code = '1') {var list = data. data. uptoken_list; uptoken = list [0] ['uptoken']; media_id = list [0] ['media _ id'];} else {alert (data. message) ;}}, error: function (XMLHttpRequest, textStatus, errorThrown) {}}); return uptoken ;}});
Reply content:
Same code
Normal Upload at www.a.com
Under www. B .com, if the same code is obtained through www.a.com, the error message "token not specified" is returned.
In uptoken_func, after the uptoken returns a null value, it is assigned a value for the data called back by ajax. Therefore, the token is empty during upload.
Var qiniu_up = qiniu. uploader ({runtimes: 'html5, flash, html4', browse_button: 'qiniu _ browse', get_new_uptoken: true, unique_names: false, save_key: true, domain :'
', Container: 'container', max_file_size: '4mb', flash_swf_url :'
', Silverlight_xap_url :'
', Max_retries: 1, dragdrop: false, drop_element: 'container', chunk_size: '4mb', auto_start: false,/* automatic Upload not enabled */multi_selection: false, /* set to select only one file */filters: {mime_types: [{title: 'image files', extensions: 'jpg, jpeg, gif, png, bmp '}, {title: 'Voice files', extensions: 'MP3, wav '}]}, init :{}, uptoken_func: function (file) {var uptoken = ''; var media_info = '[{"directory": "1", "directory_class": "", "up_file_name": "' + file. name + '"," media_type ":" 1 "}]'; $. ajax ({type: "post", async: false,/* must use synchronization */url :'
', Data: {app_version:' 1. 0', app_target: 3, sdk_version: '1. 0 ', plat: 'other', media_info: media_info}, dataType: "jsonp", jsonp: "jsonpCallback", success: function (data) {if (data. code = '1') {var list = data. data. uptoken_list; uptoken = list [0] ['uptoken']; media_id = list [0] ['media _ id'];} else {alert (data. message) ;}}, error: function (XMLHttpRequest, textStatus, errorThrown) {}}); return uptoken ;}});
The landlord's code seems to be uploading files to Qiniu CDN.
The owner of the token issue can check whether there is a JS cross-origin issue. you can also refer to the development documentation of Qiniu or contact the technical staff of Qiniu for joint debugging.
After ajax under uptoken_func is cross-origin, his running order changes. after all the programs are executed, the uptoken under success is assigned a value. Therefore, the uploaded uptoken is empty.