0

我正在尝试将一个 ajax 函数添加到一个脚本中,该脚本本质上做了两件事:

Step 1: 确定是需要搜索用户还是新建一个 Step 2: 根据选择 1,要么转到所选脚本(该部分有效),要么调用一个新函数(该部分无效,然而)。现在,我知道第二个函数本身可以完美地工作,因为我直接在锚标记中调用它并且没有任何问题,所以它必须是我在函数本身中尝试所有它的方式。这是我到目前为止所拥有的:

function changecm(){
var txt = 'Select An Option To Continue:<br>
<input type="radio" name="type" id="type" value="search" style="font-size:22px;"><br>
<input type="radio" name="type" id="type" value="create" style="font-size:22px;">';

$.prompt(txt,{ 
    buttons:{Confirm:true, Cancel:false},
    submit: function(v,m,f){
        var flag = true;
        if (v) { }
        return flag;
    },
    callback: function(v,m,f){

        if(v){      
        var type = f.type;
            if(type == 'create'){
                $.post('changecm',{type:type},
                       function(data){
                       $("div#customer").html(data);
                       }
                );
            }
            else{
            function(changecmnow);
            }
        }
    }
});

}

那是功能 1。这是功能 2:

function changecmnow(){
var txt = 'Enter the first name, last name, or telephone number of the customer to limit your results:<br>
<input type="text" name="terms" id="terms" style="font-size:22px; width:400px;">';

$.prompt(txt,{ 
    buttons:{Confirm:true, Cancel:false},
    submit: function(v,m,f){
        var flag = true;
        if (v) { }
        return flag;
    },
    callback: function(v,m,f){

        if(v){      
        var terms = f.terms;
            $.post('changecm',{terms:terms},
                   function(data){
                   $("div#customer").html(data);
                   }
            );
        }
    }
});

}

4

1 回答 1

0

如果您只想调用该函数,为什么不只是

else { changecmnow(); }

于 2012-07-12T04:18:43.247 回答