Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $ajaxScript = 'scripts/ajax.php'; // controller-script that handles all ajax script request
- /**
- * ajax wrapper
- * $_POST array of form posts
- */
- function submitAjax($_POST){
- ajaxObj = $.ajax({url:$ajaxScript, data:$_POST, type:'POST', dataType:'json' });
- return ajaxObj;
- }
- $(function(){
- $("form.ajax").submit(function(e){
- e.preventDefault();
- submitAjax($(this).serialize())
- .done(function(data,statusText,jqXHR){
- $(this).prepend('<div class="notice"><p class="icon">'+data['msg']+'</p></div>'); // *-- this triggers a "TypeError"
- console.log('done : '+statusText); // <-- this alone doesn't throw any error
- })
- .fail(function(){
- console.log('fail');
- })
- .always(function(){
- console.log('always');
- });
- });
- });
Add Comment
Please, Sign In to add comment