[英]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 这里我有变量fileVal接受文件的路径,如uploads / import / abc.pdf
var fileVal = $('#fileimport').val(); var fileVal = $('#fileimport')。val();
here fileVal takes path of file like uploads/import/abc.pdf 在这里,fileVal会采用文件的路径,例如uploads / import / abc.pdf
i have to send this file path as url variable to a php file and then display result on messagediv. 我必须将此文件路径作为url变量发送到php文件,然后在messagediv上显示结果。 like 喜欢
$('#messagediv').load('../xyz.php?file='+fileVal);
here without url variable, its working perfect getting values to the messagediv. 这里没有url变量,它的完美工作是获取messagediv的值。
But where as using url variable its not. 但是在使用url变量的地方却不是。
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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.