button with function that calling php script

button with function that calling php script

davcarnabydavcarnaby Posts: 19Questions: 0Answers: 0
edited December 2012 in General
hello, i need to set a button and on click i need to calling a php script.

I tried with ajax but does not work .

what i tried is something like this :

$.ajax({
type: "POST",
url: 'xxx.php',
data: {one:string},
success: function (response) {//response is value returned from php (for your example it's "bye bye"
alert(response);
}
});

any ideas??

Replies

  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    Assuming that you have bound the button to a click event, the ajax should work normally like any other ajax calls.
  • davcarnabydavcarnaby Posts: 19Questions: 0Answers: 0
    $('#load_all').click(function(){
    .....
    }
    );


    yes,like that. but nothing is work :(
  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    You might want to use
    [code]
    $('#load_all').live('click', function(){
    // your code
    });
    [/code]

    OR

    [code]
    $('#load_all').on('click', function(){
    // your code
    });
    [/code]
  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    edited December 2012
    This is not a DataTables specific question. This forum is specifically for DataTables, not general Javascript or jQuery. There are better places to ask, such as SO.

    Allan
This discussion has been closed.