現(xiàn)有表格中的一行的代碼如下所示:
<tr> <td><span>2</span></td> <td>公司介紹</td> <td>內(nèi)部欄目</td> <td><span target='_blank'>服務(wù)器傳遞數(shù)據(jù) 方法為post方法
5、提交數(shù)據(jù)的時候,友好提示修改中。。。 或者等待圖片
6、返回成功信息 ,重新顯示修改后的內(nèi)容 去掉input框
實現(xiàn)這一功能的jquery核心代碼如下:
$('.listorder').click(function(e){ var catid = $(this).parent().siblings("td:eq(0)").text();//獲取同一行上 第一列中的id值 var listorder_now_text = $(this).text();//獲取listorder中的內(nèi)容 先保存起來 $(this).text("");//設(shè)置內(nèi)容為空 var list_form = '<input type="text" value="'+listorder_now_text+'" size=2 />' ; $(this).parent().append(list_form); //插入 input框 $(".listorder_input").focus();//自定義一個div 提示修改中 var loading = '<div><img src="img/loading.gif" $(this).parent().append(loading); $('#loading') .css({"color" : "red" ,"display" : "none" })//定義ajax的全局事件 $(this).ajaxStart(function(){ $('#loading').show(); }) $(this).ajaxStop(function(){ $('#loading').remove(); }) $(".listorder_input").blur(function(){ var thislist = $(this).siblings(); //取得同級的標(biāo)簽 即 修改后需要顯示的 listorder $.post("ajax.php",{ action : "mod_listorder", catid : catid , listorder : $(this).attr("value") } , function(data, textStatus){$(thislist).text(data);} );//end .post $(this).remove(); })//end function blur})// end function click
ajax.php中內(nèi)容就簡單了,這里只做處理做演示用,并沒有向服務(wù)器提交數(shù)據(jù),代碼如下:
sleep(1);//延時運行1秒,查看效果用,實際代碼中不需要echo $_POST['listorder'];
新聞熱點
疑難解答
圖片精選