Javascript - 通过Ajax在字符串中发送html代码

How is the best way to send string from javascript to php with html tags inside? I'm trying, but all html tags disappear.

var ajaxData = '<div>some <b>text</b></div>';

jQuery.ajax({
            url: url,
            type: 'POST',
            dataType: 'json',
            data: ajaxData,
});

but in my php code var_dump($input); shows string like that: 'some text' instead

'<div>some <b>text</b></div>'

even this doesn't work

htmlspecialchars(urldecode($input));

did you tried to view source? var_dump will output the variable as is, so if it contains HTML the browser will parse it and you won't see the HTML part (only in view source).

try to escape it before using var_dump.

var_dump(htmlspecialchars($input));

Can you take a look at the page source for the page where you're doing the var_dump? I suspect your browser is actually parsing the div and b tags, so the HTML is not showing up in the text...