Popular Posts
Export list schema from sharepoint http:// YOUR_SERVER_URL / PATH_TO_SITE_CONTAINING_LIST /_vti_bin/owssvr.dll?Cmd=ExportList&List= {YOUR_LIST_GUID} JSRequest, Get parameters from querystring with javascript in SharePoint Provides method to parse query string, filename, and pathname from URL // Initialize first JSRequest.EnsureSetup(); // Get the current fil... ROBOCOPY: Robust File Copy for Windows -------------------------------------------------------------------------------    ROBOCOPY     ::     Robust File Copy for Windows --------...
Stats
jQuery : post/get using data() as param object
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Recursive call when post request</title>
<script type="text/javascript" src="jquery-1.5.1.js"></script>
<script type="text/javascript">
    $(function() {
        var count = 0;
        $('input:button').click(function() {
            // identity
            count++;
            var tick = count;
            // post url
            var url = '${contextPath}/';
            // post param
            var param = $(this).data();
            console.log(param);
            $('<div>(' + tick + ') Post to : ' + url + '</div>').appendTo(document.body);
            $.post(url, param, function(data) {
                $('<div style="color:blue;">(' + tick + ') Ajax works successfully.</div>').appendTo(document.body);
            });
        });
    });
</script>
</head>
<body>
<input type="button" value="click to post" data-action="test" data-name="bruce" data-age="31" />
</body>
</html>
ボタンをクリックすると、data()のオブジェクトがハンドルを値を持っているため、postするときにハンドルは再び執行することになる。つまり、クリック事件は繰り返しする。この現象を避けるには、ハンドル/イベントを削除しなければならない。
View mobile version