click even have two connected movements

click even have two connected movements

I met a very strange question, click even have two connected movements


I use jquery js code to load the dynamic features required to load the appropriate procedures js


The work load is usually regarded as normal, but sometimes abnormal


Reload the page, the location of newly hatched problem will not necessarily be a problem


In short very random


For example the following code
When you click on the corresponding object, it will trigger to load the js file, and perform the functions file
  1.     $('#project').click(function(){
            if(typeof(global_js.project) == 'undefined'){
                $.ajax({type:'get',
                    url:"js/project.js",
                    dataType:'script',
                    cache:gim.ajax_cache,
                    success:function(){
                        global_js.project=true;
                        load_project_page();
                }});
            }else{
                load_project_page();
            }
        });














At this time, the program works, through the firebug to see the process as shown in Figure




When a problem occurs, there are plans



Jquery will load the file that is twice, but a connection will be blocked
Leading to the success operation can not deal with ajax


Using POST or GET to have a similar situation




For example, the following code is POST data, presented two cases sometimes occur


  1.     $('#project_business_ul .delete').livequery('click',function(){
            d = new Object();
            d.t = 'delete';
            d.bid=bid;
            d.pid=pid;
            d.cost=cost;   
            d.name=escape(name);
            $.ajax({type:'post',
                url:"project_summary.php",
                dataType:'json',
                data:{d:JSON.stringify(d)},
                success:function(h){
                    if(h != null) {
                        switch(h.php_status) {
                             case 'ok':
                                                           
                            break;
                        }
                    }
            }});
        });



















Figure







Of course, the actual submission of a connection to the server only once, after all, write the data only once


So I think it is a problem with jquery ajax code


Which there a way around it?