Dauezevy
Dauezevy

Reputation: 1080

JQuery Function Call in another function

$.save1= function(){
    var value = $("form#form1").serialize();
    send(value);
}

$.save2= function(){
    var value = $("form#form2").serialize();
    send(value);
}

$.save3= function(){
    var value= $("form#form3").serialize();
    send(value);
}

$.send= function(value){
    value = value + "&do=titlechange";
    $.ajax({
        url: "php_script.php",
        data: value,
        dataType: "json",
        type:"post",
        success: function(res){
            alert(res);     
        }
    });
}

I have 3 different form in same page. Also i have 3 different button, but i want to send values to same .php file. My code is above, but i could not call send function, in "save" functions. Save functions are binded buttons onclick.

Upvotes: -1

Views: 51

Answers (1)

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

Replace send(value); with $.send(value); as you're creating function with variable name $.send.

$.save1= function(){
    var value = $("form#form1").serialize();
    $.send(value);
}

$.save2= function(){
    var value = $("form#form2").serialize();
    $.send(value);
}

$.save3= function(){
    var value= $("form#form3").serialize();
    $.send(value);
}

$.send= function(value){
    value = value + "&do=titlechange";
    $.ajax({
        url: "php_script.php",
        data: value,
        dataType: "json",
        type:"post",
        success: function(res){
            alert(res);     
        }
    });
}

Upvotes: 2

Related Questions