0
好日子每一個,我與阿賈克斯工作,以檢查值是否相同或不,我得到真正的數據成功的Ajax,但是當我使用如果聲明爲JS警報其給我相反的結果,請assist-這裏是我的代碼 -如果語句給予ajax成功相反的結果
的index.php
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script type="text/javascript">
$(function() {
setInterval("alert()", 5000);
});
function alert() {
var aval=1;
$.ajax({
type: "POST",
url: "php.php",
data: 'uid=' + aval,
success: function(html)
{ // this happen after we get result
if (html.success == true)
{
alert ('Same Value');
}
else {
alert('Different Value')
}
}
});
}
</script>
Old Value:1<br>
<div>New Value:</div><div id="new" ></div>
php.php
<?php
//some php coding which shows result
echo '1';
?>
我同意,你也應該接受的答案 – 2015-09-09 10:02:47