This looks like exactly what I need!
But read this 5 times and cannot find anything working.
Is there no example?
Thanks
]]>Support is also available on GitHub https://github.com/Hube2/blunt-ajax
]]>Hey, just a suggestion. It would be cool, if you could include a real life example to your “other notes”. That would make it a lot easier to understand how to use it. And also you got some typos there.
]]>Hello, this is my original code that I am trying to work on wordpress:
function ajaxUploadOwnFile(){
$.ajaxFileUpload({
url:'ownfileupload.php',
secureuri:false,
fileElementId:'ownFileToUpload',
dataType: 'json',
success: function (data){
$('#ownFileToUpload').val('');
if (data.status != 'error'){
var file_name = data.file_name;
//saving our file name into cookie session
var user_files = $.cookie('user_files') != undefined ? $.cookie('user_files') : '';
if (user_files == '')
user_files = file_name;
else
user_files += ',' + file_name ;
$.cookie('user_files', user_files, { expires: 1 });
set_items_drag();
} else {
alert(data.error);
}
},
error: function (data, status, e){
alert(e);
}
});
}
This is the modified code with Blunt Ajax
function ajaxUploadOwnFile(){
var arguments = {
debug:true,
url: "/test/wp-content/themes/toolbox/ownfileupload.php",
callback: $.ajaxFileUpload,
method:"POST",
element_id:'ownFileToUpload',
pass:function (data){
$('#ownFileToUpload').val('');
if (data.status != 'error'){
var file_name = data.file_name;
//saving our file name into cookie session
var user_files = $.cookie('user_files') != undefined ? $.cookie('user_files') : '';
if (user_files == '')
user_files = file_name;
else
user_files += ',' + file_name ;
$.cookie('user_files', user_files, { expires: 1 });
set_items_drag();
} else {
alert(data.error);
}
},
error: function (data, status, e){
alert(e);
}
};
bluntAjax(arguments);
}
Can you please tell me what I am doing wrong?
]]>Please be aware that parameters are not escaped properly.
Prior to making this a WP plugin I passed parameters to the script as a query string rather than as an object. This required that I url encoded the values before the I passed them. I’ve been using this script so long it was just a habit.
I was recently building a new feature that required a value with a space in it which caused a problem.
I will update this plugin at some point to include an argument parameter that will cause values to be automatically escaped. I will make this argument default to false to maintain backward compatibility with the current version.
For now, you will need to url encode values before calling Blunt Ajax if there are any characters in your values that need escaping.
my_var = encodeURI(my_var)
]]>