gpt4 book ai didi

PHP Echo 将 HTML 转换为文本

转载 作者:行者123 更新时间:2023-11-30 13:19:03 29 4
gpt4 key购买 nike

我有一个脚本来回应用户的选择:

<script>
function onSuccess(data, status)
{
data = $.trim(data);
$("#car-check").text(data);
}

function onError(data, status)
{
// handle an error
}

$(document).ready(function() {
$("#submit").click(function(){

var formData = $("#car-locationform").serialize();

$.ajax({
type: "POST",
url: "pages/callajax.php",
cache: false,
data: formData,
success: onSuccess,
error: onError
});

return false;
});
});
</script>

选择区域:

<ul class="print-menu">
<li>
<label for="select-choice-0" class="select">Parking Method:</label>
<select name="parkingoption" id="parkingoptions" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
<option value="">Select One</option>
<option value="Self Parking">Self Parking</option>
<option value="auto">Valet Parking</option>
</select>
</li>
<li>
<div class="self carlocation">
<h1>Enter Car Location:</h1>
<label for="select-choice-0" class="select">Floor:</label>
<select name="locationfloor" id="locationfloor" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
<option value="">Floor Select</option>
<option value="1">F1</option>
<option value="2">F2</option>
<option value="3">F3</option>
<option value="4">F4</option>
</select>
</div>
</li>
<li>
<div class="self car-position">
<label for="select-choice-0" class="select">Row:</label>
<select name="select-choice-15" id="positionrow" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
<option value="">Row Select</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
</div>
</li>
<li>
<div class="self car-section">
<label for="select-choice-0" class="select">Section:</label>
<select name="select-choice-15" id="positionrow" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
<option value="">Section Select</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="F">F</option>
<option value="G">G</option>
</select>
</div>
</li>
<li>
<div class="self car-section">
<label for="select-choice-0" class="select">Spot:</label>
<select name="select-choice-15" id="position-row" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
<option value="">Spot Select</option>
<option value="1-A">1-A</option>
<option value="2-B">2-B</option>
<option value="3-C">3-C</option>
<option value="4-D">4-D</option>
<option value="5-E">5-E</option>
<option value="6-F">6-F</option>
<option value="7-G">7-G</option>
</select>
</div>
</li>
<div class="self car-submit">
<button id="submit" type="submit" name="submit" value="submit" data-theme="b">Submit</button>
</div>
</ul>
<div id="car-check"></div>

Ajax 页面:

<?php
$parktype = $_POST["parkingoption"];
$carfloor = $_POST["locationfloor"];
echo "<h1>Park Type: $parktype </h1>" ;
echo "<br/>";
echo "<span> Park Type: $parktype </span>";
?>

用户选择的内容最终会出现在#car-check 中。但出于某种原因,回显中的 HTML 只是以文本形式出现。我只是暂时从 $parktype 开始,只是为了测试。

任何帮助将不胜感激,谢谢!

更新——

谢谢大家我觉得完全没有注意到这一点很愚蠢。

最佳答案

$("#car-check").text(data); 更改为 $("#car-check").html(data);

关于PHP Echo 将 HTML 转换为文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10953990/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com