简体   繁体   中英

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?

尝试使用encodeURIComponent()

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

That should work fine except you have a syntax error

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM