jaya
jaya

Reputation: 327

how i can pass string variable with url in load function?

here i have variable fileVal takes path of file like uploads/import/abc.pdf

var fileVal = $('#fileimport').val();

here fileVal takes path of file like uploads/import/abc.pdf

i have to send this file path as url variable to a php file and then display result on messagediv. like

  $('#messagediv').load('../xyz.php?file='+fileVal);

here without url variable, its working perfect getting values to the messagediv.

But where as using url variable its not.

How i can solve this?

Upvotes: 2

Views: 562

Answers (2)

Kanishka Panamaldeniya
Kanishka Panamaldeniya

Reputation: 17566

try with encodeURIComponent()

var fileVal =  encodeURIComponent($('#fileimport').val());

Upvotes: 1

Popnoodles
Popnoodles

Reputation: 28409

That should work fine except you have a syntax error

// $var fileVal = $('#fileimport').val();
var fileVal = $('#fileimport').val();

Upvotes: 0

Related Questions