jquery提供的数据提交方式1

1,ajax提交,部分代码为easyui

function editNode(id){
    $.ajax({
        dataType:'json',
        async:true,        //默认的就是异步提交
        type:'post',
        url:"__APP__/控制器/方法",
        data:{id:id},
        success:function(data){
            row = eval('('+data+')');        //计算某个字符串,并执行其中的的 JavaScript 代码
            if (row){
                $('#dlg-form').form('clear');
                $('#dlg').dialog('open').dialog('setTitle','编辑');
                $('#dlg-form').form('load',row); 
                
                $("[name^=tuitype]").each(function(){
                    var val=$(this).val();
                    if(row.tuitype.indexOf(val)>-1){                         
                    $(this).attr("checked",true);
                    }
                });
            }else{
                $.messager.show({
                    title: '出错啦!!',
                    msg: '请选择一条'
                });
            }
        }
    });
}

 2,ajax的load传递方法

load(url, [data][callback])

url:待装入 HTML 网页网址。

data:发送至服务器的 key/value 数据。在jQuery 1.3中也可以接受一个字符串了。

callback:载入成功时回调函数。

$("#btnAjaxCallBack").click(function()
{
    //发送Post请求, 返回后执行回调函数.
    $("#divResult").load("./AjaxGetMethod.php",{"param": "btnAjaxCallBack_click"}, function(responseText)
    {
        responseText = " Add in the CallBack Function! <br/>" + responseText;
        $("#divResult").html(responseText); //或者: $(this).html(responseText);
    });
});

 

posted on 2015-04-30 18:47  hrbust_09zhangyabin  阅读(175)  评论(0编辑  收藏  举报