gpt4 book ai didi

php - 错误控制台显示 "function not defined"

转载 作者:行者123 更新时间:2023-11-28 12:46:52 25 4
gpt4 key购买 nike

错误控制台显示以下错误:

Error: review is not defined Source File: http://localhost/opencart/index.php?route=information/savingsaccount Line: 1

 <script type="text/javascript">
function review(id) {
$.ajax({
alert(id);
text = $.trim($("#text").val());
name = $.trim($("#name").val());
rating = $.trim($("#rating").val());

url = "savingsreview.php";
data = "name="+name+"&text="+text+"&rating="+rating;
result = $.ajax({
url: url,
global: false,
type: "GET",
data: data,
async:false,
beforeSend: function(){
},
}
).responseText;
alert(result);
}
});
}

</script>
<div style="width:540px;" align="center"><a id="displayText"
href="javascript:toggle(<?php echo $id;?>);">Review & Read Reviews</a></div>
<span id="toggleText<?php echo $id;?>" style="display: none">


<div class="content">


<label><b>Your Name</b></label> : <input type="text" id="name" name="name" value="" />

<label><b>Your Review</b></label> :<textarea name="text" id="text" rows="3"> </textarea>

<label><b>Rating</b></label>
<input id="rating" type="radio" name="rating" value="1" style="margin: 0;" />
&nbsp;
<input type="radio" name="rating" value="2" style="margin: 0;" />
&nbsp;

<a onclick="review(<?php echo $id;?>);" class="button"><span>Submit</span></a></td>

</span>


Can anyone help me solve this??

最佳答案

试试这个

function review(id) {

alert(id);
var text = $.trim($("#text").val());
var name = $.trim($("#name").val());
var rating = $.trim($("#rating").val());

var url = "savingsreview.php";
var data = "name=" + name + "&text=" + text + "&rating=" + rating;
var result = $.ajax({
url: url,
global: false,
type: "GET",
data: data,
async: false,
beforeSend: function() {},
}).responseText;
alert(result);


}

有一些垃圾,所以我删除了它,它应该可以工作(就像 function review(id) { 之后的 $.ajax() )

关于php - 错误控制台显示 "function not defined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6788411/

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