var ajaxurl = "<?php echo get_stylesheet_directory(); ?>";
where get_stylesheet_directory() = D:'Copy'wamp'www
console.log(ajaxurl);
显示D:Copywampwww
我不知道为什么"/"被删除,而存储变量
even if try
var ajaxurl = "D:'Copy'wamp'www";
显示"D:Copywampwww"
只有var ajaxurl = "D:'Copy'wamp'www";将工作,但任何人都可以帮助
"D:'Copy'wamp'www"="D:''Copy''wamp''www"
在PHP中?
转义字符。
您需要转义字符串中的'
。
在php中可以使用echo json_encode(get_stylesheet_directory());