Ajax Js to PHP without reload page

$(document).ready(function () { //EXCEPTION SUBMIT $('#f_1').on('submit', function(e) { e.preventDefault(); $.ajax({ url : "action.php", type: "POST", data: $(this).serialize()+'&s1=true', //s1 - name/id for submit button on the form; success: function (data) { //return some data from php and put it in #output_succ $("#output_succ").html("Changes in ... with "+data+" have been applied successfully!"); }, error: function (jXHR, textStatus, errorThrown) { alert(errorThrown); } }); }); });
What is this related to:
1. U have a form with data;
2. U want to send this data from js to php for processing and get the result back;
3. U dont want to interrupt user with reloading of a page;
4. U want to put some msg with result somewhere;

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.