[英]Uncaught ReferenceError: text is not defined in my javascript
I am trying to submit to a database, using php and jquery (see code snippet below).我正在尝试使用 php 和 jquery 提交到数据库(请参见下面的代码片段)。
<script>
$(document).ready(function() {
$('#butsave').on('click', function() {
$("#butsave").attr("disabled", "disabled");
var idno = $('#idno').val();
if(idno!=""){
$.ajax({
url: "common/register-details.php",
type: "POST",
data: {
name: idno
},
cache: false,
success: function(dataResult){
var obj = JSON.parse(text);
var dataResult = JSON.parse(dataResult);
if(dataResult.statusCode==200){
$("#butsave").removeAttr("disabled");
$('#register-id').find('input:text').val('');
$("#success").show();
$('#success').html('Data added successfully !');
}
else if(dataResult.statusCode==201){
alert("Error occured !");
}
}
});
}
else{
alert('Please fill all the field !');
}
});
});
</script>
However i get the following error但是我收到以下错误
ReferenceError: text is not defined
When I use php with no jquery it works.当我使用没有 jquery 的 php 时,它可以工作。 Could anybody please tell me what the error could be?有人可以告诉我错误可能是什么吗?
you are doing var obj = JSON.parse(text);
你在做var obj = JSON.parse(text);
, there is no text
. ,没有text
。
Remove this line删除此行
var obj = JSON.parse(text);
as there is no text variable declared.因为没有声明文本变量。
This will solve your issue.这将解决您的问题。
Still your program not work then put your HTML code clock, php code block and javascript/jquery code block in question.您的程序仍然无法工作,然后将您的 HTML 代码时钟、php 代码块和 javascript/jquery 代码块置于问题之中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.