3
我做的,被調用的缺乏從頁面更好的詞的功能,讓稱它爲第1頁,單擊一個按鈕,當函數被調用,以表示函數結束它會調用另一個創建(或應該看到我無法測試它)html並將其附加到具有#lista id的div。製作功能在另一個頁面影響因素
問題是,這個div是另一個頁面(Page2),所以我不知道是否有像ajax這樣的語法,你指定你想要這些值去的地方,所以基本上頁1調用一個函數(上以防萬一),另一個文件中的函數調用另一個和函數的結果,以防萬一)
這裏去第一頁上(另一個文件,又是我的jQuery/JS代碼來進一步說明:
$("#btnAceptar").click(function() {
var idlab = $('#txtNumLab').val(),
capacidad = $('#txtCapacidad').val(),
carrera = $('#txtCarrera').val(),
ubicacion = $('#txtUbicacion').val();
var request = $.ajax({
url: "includes/functionsLabs.php",
type: "post",
data: {
'call': 'addLab',
'pIdLab':idlab,
'pCapacidad':capacidad,
'pCarrera':carrera,
'pUbicacion':ubicacion},
dataType: 'json',
success: function(response){
alert('exito')
agregar();
}
});
});
此函數應該會影響第2頁上的id爲#Lista的元素。
function agregar(){
var div = $("#lista").append("<div class='box'>
<p>Lab #'numero'</p>
<p class='info'><a href='#' id='lnkInfo'>Info</p></a>
<p class='info'><a href='reservarLab.html'>Reservar</p></a>
</div>");
div.id = querySelectorAll('#lista > div').length +1;
var numero = div.id;
$('#numero').append(div);
}
非常感謝!
另一頁面作爲在其他標籤/窗口,或在一個頁面,用戶最終將導航到? –
可能重複:http://stackoverflow.com/questions/7709289/how-to-pass-javascript-object-from-one-page-to-other –
@PatrickEvans,另一頁是另一個文件中的函數調用上Page1.php,第二個函數是爲了影響Page2.php中的元素。這兩者都在同一個文件夾中,並且是同一整體的一部分。 –