完成后,我可以使jQuery post()工作,但不能将load()的新页面加载到div中。
我正在尝试制作一个单页Web应用程序www.drivetoyourvacation.com,并且正在尝试使用jQuery .post()和.load()来做到这一点。我填写了第一个表单以捕获名称和电子邮件以发送到数据库,然后在DIV中加载了下一个表单,表单中已填写了姓名和电子邮件。很好然后,我在新页面上的下一个.post()内有另一个.load(),并且它的post部分有效,并且下一组数据被放入数据库中,但下一页未加载。我可以使用按钮手动获取下一页,然后使用相同的代码单击功能
<http://drivetoyourvacation.com/new/test.html>
will load <http://drivetoyourvacation.com/new/signup.php> into the form div
then im trying to get <http://drivetoyourvacation.com/new/pay.php>
to load into that div but only loads when the button is used which I just setup as a test and isn't how I want to do that.
任何帮助将不胜感激!
<script>
$(document).ready(function(){
//This works
$('#newpage').click(function(){
$('#page').load('pay.php', {'id':id});
return false;
});
$('#theform').submit(function(){
$('#loading').html("<b>Loading Payment Page...</b>");
$.post('process.php', $(this).serialize(), function(data){
//This doesn't work
$('#data2').html(data);
//This works
var id = (result.id);
$('#id').html(id);
//This doesn't work
$('#loading').load('pay.php', {'id':id});
}).fail(function() {
alert( "Registration failed, please contact us for
assistance" );
});
return false;
});
});
</script>