可能重複:
Detecting Ajax in PHP and making sure request was from my own website如何確保使用ajax?
我有一個表格上傳圖片,我使用Ajaxform()
$('#uploadformimage').ajaxForm({
beforeSend: function() {
$(".progress").css("display","block");
$("#response").html("");
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
//console.log(percentVal, position, total);
},
complete: function(xhr) {
$(".bar").css("width","100%");
$(".percent").html("100%").delay("8000").parent().slideUp(1000);
$("#response").html(xhr.responseText);
}
});
這是我的javascript代碼。我想搞清楚server-side
表單是否由ajax上傳? Javascript可能在某些計算機上被禁用,因此我想顯示一些不同的數據?
在問你的問題之前,請使用搜索。我只是在搜索中粘貼問題標題:http://stackoverflow.com/search?q=%5Bphp%5D+How+to+make+sure+ajax+is+used+or+not%3F - 請參閱http: //hackoverflow.com/questions/ask-advice – hakre
@hakre它不是每個人都知道的一切。你應該看到這個[User hakre](http://stackoverflow.com/questions/6562276/how-to-merge-兩個數組 - 由僅接受數值 - 第二陣列 - 那 - 哈) – StaticVariable
這是沒有藉口不使用搜索。 – hakre