Tuesday, December 22, 2009

[jQuery] Passing a string via variable results in NaN

I've got a little problem with passing two strings $FilePath and
$FileName to the PHP file and I've got no clue why. When I do it this
way everything's Ok

ppost : {
'Path' : 'temp/',
'File' : 'Myfile.jpg'
},

Of cause I need to do this via variable but when I do it in this way:

$FilePath ="temp/";
$FileName ="Myfile.jpg";

ppost : {
'Path' : [+$FilePath],
'File' : [+$FileName]
},

Everything that my PHP code recives is NaN for both variables. Could
you tell me why and what would be the proper way?

The entire script:

function ajaxFileUpload()
{
$("#loading")
.ajaxStart(function(){
$(this).show();
})
.ajaxComplete(function(){
$(this).hide();
});
$FilePath ="temp/";
$FileName ="Myfile.jpg";

$.ajaxFileUpload
(
{
url:'doajaxfileupload.php',
secureuri:false,
fileElementId:'fileToUpload',
ppost : {
'Path' : [+$FilePath],
'File' : [+$FileName]
},
dataType: 'json',
success: function (data, status)
{

},
error: function (data, status, e)
{
alert(e);
}
}
)

return false;

}

No comments: