我完全失去了如何工作AJAX。看了一些教程,都顯得很混亂。我遇到了這個問題:[Script only runs once]。AJAX加載內容
我會用它來重新加載頁面,如下所示:[http://www.roblox.com/Poison-Horns-item?id=62152671]所以我可以得到最新的物品價格,而不刷新頁面。如果任何人能夠幫助/告訴/指向正確的方向,它會幫助噸。
林有些新手編劇,所以要有點耐心;)
感謝您的幫助, 亞歷
我完全失去了如何工作AJAX。看了一些教程,都顯得很混亂。我遇到了這個問題:[Script only runs once]。AJAX加載內容
我會用它來重新加載頁面,如下所示:[http://www.roblox.com/Poison-Horns-item?id=62152671]所以我可以得到最新的物品價格,而不刷新頁面。如果任何人能夠幫助/告訴/指向正確的方向,它會幫助噸。
林有些新手編劇,所以要有點耐心;)
感謝您的幫助, 亞歷
AJAX請求是相同的頁面請求(GET和POST),除了他們是異步處理並且不離開當前頁面。響應數據是您想要獲取的頁面的來源。在解析/使用它之前,這個源代碼是無用的。
一個簡單的jQuery例如:
//for example, we are on example.com
$.ajax({
type : 'get', //the METHOD of the request, like the method of the form
url : 'index.php' //the url to fetch
data : { //additional data which is synonymous to:
query1 : 'foo', // - url queries
query2 : 'bar', // - form inputs
query3 : 'baz',
},
success : function(resposeText){ //response text is the raw source of the fetched resource
$(element).html(responseText); //use response as HTML for element
}
});
//this is similar to requesting:
http://example.com/index.php?query1=foo&query2=bar&query3=baz
同意約瑟夫。您可以通過JavaScript方式或通過jQuery使用ajax,我個人建議jQuery,因爲它很容易實現。
$.ajax({
type: 'GET',
url: "URL you want to call" ,
data: 'Data you want to pass to above URL',
cache: true, //to enable cache in browser
timeout: 3000, // sets timeout to 3 seconds
beforeSend: function() {
//when ur ajax call generate then u can set here loading spinner
},
error: function(){
// will fire when timeout is reached
},
success: function(response){
//in response you can get your response data from above called url.
}
});
因此,如果我想在此頁面上重新載入包含'Private Sales'的表格:[http://www.roblox.com/Poison-Horns-item?id=62152671] – Alex