dongying6179 2012-12-20 17:02
浏览 16

ajax和php简报注册表格[关闭]

I'm building a form that uses ajax and php to validate an email address that a user has submitted. I'm about intermediate when it comes to php but with ajax i'm afraid I'm a novice.

I've done all the php and know it will work fine, problem is how do I make the ajax process the php script, currently I have created a function in ajax called completeSignup(); and it looks as:

function completeSignup() {
    setTimeout(function() {
        $("#completeform").fadeOut(400, function(){
            $(this).before('<span class="done">All done! We will be in     touch.</span>');
        });
    }, 1100);
}

How do include the php script inside the function and keep it all on the same page?

Thanks

  • 写回答

1条回答 默认 最新

  • dtjo51649 2012-12-20 17:08
    关注

    You are not doing an ajax request anywhere. When using jquery you can do ajax queries using methods like post() or ajax(). if you give a look at the documentation by jquery, you will find loads of examples on how to do an ajax query with/without sending data to a php file.

    http://api.jquery.com/jQuery.post/

    http://api.jquery.com/jQuery.ajax/

    check the examples..

    just a basic example here..

    $.ajax({
    type: "POST",
    url: "some.php",
    data: { name: "John", location: "Boston" }
    }).done(function( msg ) {
    alert( "Data Saved: " + msg );
    });
    

    some.php file will contain your php logic. just for test purpose, echo something in that file and die. You will understand the whole thing in a better way then.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法