I am trying to add an ajax function to a script that does 2 things essentially:
Step 1: Determine if it needs to search for users or create a new one
Step 2: Based on selection 1, it will either go to the selected script (that part works) or call a new function (that part doesn’t work, yet). Now, I know the 2nd function itself works perfectly as I called it directly in the anchor tag and had no issues, so it has to be in how I am trying to all it witin the function itself. here’s what I have so far:
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);
}
}
}
});
}
That’s function 1. Here’s function 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);
}
);
}
}
});
}
if you just want to invoke the function, why not just
else { changecmnow();}