我想通過一個可能包含'+'符號的變量,但是在傳入下一頁後,它會變爲連接。 '2 + 2',從first.php到second.php在second.php上顯示爲'2 2',但我只需要'2 + 2',同樣對'2-2'也適用。這是我的first.php在JS變量中傳遞'+'符號
<script>
$(document).ready(function() {
$("#sub").click(function() {
var txt1 = $("#userquery").val(); //textbox value
$.ajax({
type: "POST",
url: "second.php",
cache: false,
data: "txt1=" + txt1,
dataType: "html",
success: function(result) {
$("#sqlresult").html(result);
}
});
});
});
</script>
<textarea id='userquery' rows='5' cols='115' spellcheck='false' wrap='off' placeholder='Write SQL query here..'></textarea>
<input id='sub' type='submit' value='Execute' title='Ctrl+Enter'>
<hr><div id='sqlresult'><?php include('second.php'); ?></div>
非常棒!它的工作,答案接受。謝謝 –