开发者

how to modify query string whose filter value contains &

开发者 https://www.devze.com 2023-02-24 05:42 出处:网络
I have constructed an URL like - http://server_name/_vti_bin/owssvr.dll?Cmd=Display&List={List-Id}&XMLDATA=TRUE&View={View-Id}&Query=*&FilterField1=Country_x0020_Name&FilterVa

I have constructed an URL like -

http://server_name/_vti_bin/owssvr.dll?Cmd=Display&List={List-Id}&XMLDATA=TRUE&View={View-Id}&Query=*&FilterField1=Country_x0020_Name&FilterValue1=UK & Ireland

which ofcourse doesnot give me the expected output. How to specify the filer value if there is an '&' character in the string? The filter value is retrieved from a sharepoint list that contai开发者_JS百科ns the list of countries


You need to encode the value of the filter parameter according to RFC 3986. If you're building the url using javascript, then you would do this using a call to encodeURIComponent(rawData):

var url = hostpath + "?Query=" + encodeURIComponent(filterValue);

This will take care of '&', spaces and other characters that would otherwise cause a problem. If you're hard-coding the URL, then you can use one of the many public access tools to see what the encoded value should look like, e.g. W3Schools.com

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号