基本的に2つのことを行うスクリプトにajax関数を追加しようとしています:
ステップ 1: ユーザーを検索する必要があるか、新しいユーザーを作成する必要があるかを判断する ステップ 2: 選択 1 に基づいて、選択したスクリプトに移動する (その部分が機能する) か、新しい関数を呼び出す (その部分が機能しない、まだ)。これで、アンカータグで直接呼び出して問題がなかったため、2番目の関数自体が完全に機能することがわかったので、関数自体の中ですべてをしようとしている必要があります。これが私がこれまでに持っているものです:
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);
}
);
}
}
});
}