javascript - Remove prefix from string with .split results in Unexpected token ILLEGAL -
i have string strange prefix , i've tried using split function return array after slash character "\". string: i:0#.w|itun\allepage_fg
this tried:
function claimorder(){ var user = $().spservices.spgetcurrentuser({ fieldname: "name", debug: false }); var trimuser = user.split("\"); $().spservices.spfindpeoplepicker({ peoplepickerdisplayname: "napa user", valuetoset: trimuser[1], checknames: true }); }
i error: unexpected token illegal
you need escape backslash inside string literal:
var trimuser = user.split("\\");
in future, when error that, tell relevant line. case obvious, won't be.