解决方案 »

  1.   

    ajax提交表单,最简单的那种,不过不用submit而是button,button的id为sub,form表单的id为form1,post方式提交。我不会ajax
      

  2.   

    手写一段ajax吧  可能有错误$(function(){  $('#sub').click(function(){//点击按钮提交
                                            //要提交的表单id为form1
                       
                $.ajax({
                     url:"xxxxx",
                     data:$("#form1").serialize(),
                     type:"post",
                     success:function(data){//ajax返回的数据
                     }
                });     
            });
    });
      

  3.   


    //保存
            $('#BtnSave').click(function () {
                var previewOptions = {
                    beforeSubmit: validateForm,
                    url: '/ContentVerify/DoCreateOrEdit',
                    type: 'POST',
                    dataType: 'json',
                    success: function (result) {
                        if (result.Success) {
                            ShowMsg("保存成功!", "/ContentVerify/Index");
                        }
                        else {
                            ShowMsg("保存失败!" + result.Msg);
                        }
                    },
                    iframe: false
                };            $('#doform').ajaxSubmit(previewOptions);
                return false;
            });
      

  4.   

    前提是要引用 jquery.form.js  和 jquery.js
      

  5.   

    url这部分怎么写,我用的是php,action是一个对象的方法
      

  6.   

    这个简单你ajax完了之后 调用form的submit $.ajax({
               url:"xxxxx",
               data:$("#form1").serialize(),
               type:"post",
               success:function(data){//ajax返回的数据
               }
             });
    $("#form1").submit();记住用此调用时你的HTML的form里不能有<input type = 'submit' />submit按钮 不然你点button就会刷新页面
      

  7.   

    url这部分怎么写,我用的是php,action是一个对象的方法
    我一般怎么写Interface.php写接口
    然后data传入参数 找到Interface.php这个文件里面的你想调用的函数
    这里我传入"GetJoke"
    $.ajax({
    type : "POST",
    url : "../php/Interface.php",
    data : {
    Index : "GetJoke",
    curpage : curpage,
    countPerPage : countPerPage,
    joketype : joketype
    },
    dataType : "json",
    async : false,
    success : function(data) {}
    Interface.php
    $index = $_POST["Index"];
    switch ($index) {
    case 'GetJoke' :
    GetJoke();
    break;

    function GetJoke() {
    $curpage = $_POST['curpage'];
    $joketype = $_POST['joketype'];
    $CountPerPage = $_POST['countPerPage'];
    $sidx = 'uploaddate';
    $sord = 'desc';
    $where = '1=1';

    $where .= " AND joketype = '" . $joketype . "'"; $clsSql = new UserOp();
    $result = $clsSql -> GetJoke($curpage, $CountPerPage, $sidx, $sord, $where);
    echo json_encode($result);
    }
      

  8.   

    $.ajax({
      url : "",   请求的Url
      data : {  }, 参数Json格式
      dataType : "json", 请求的返回类型 这里为json
      type : "post",  提交方式
      cache : false,  是否异步提交
      success : function(result)
      {
            alert('回调函数');
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('错误处理');
      }});
      

  9.   

    我来贴一段我写的java版本的ajax登录提交  $.ajax({
                                 type:"get",
                                 url:"vote.do?action=ajaxLoginSys&r="+Math.random(),
                                 contentType:"application/x-www-form-urlencoded; charset=GBK",
                                 data:{user_name:user_name,pass_word:pass_word},
                                 dataType:"text",
                                 success:function(data){
                                     flag = true;
                                     $("#loginflag").val("1");//设置登录标志位
                                     changeHtml(data);
                                 }//success
                                 });//Ajax