SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Ajax POST

  1. #1
    SitePoint Evangelist silversurfer5150's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Ajax POST

    Hi there guys,

    Take a look at the following code:

    Code:
    $( "#reorder" ).click( function(e) {
      e.preventDefault();
    			  $holder = $('#form1').serializeArray(); //gets everything from the form and puts it in associative array (holder)
    		$.ajax({ 
    			type: 'POST',
    			url: 'http://will.site88.net/jake/multimedia.php',     //send array data to payment/check method confirm
    			data: $holder ,
    			success: function() {
    			location = 'http://will.site88.net/jake/multimedia.php';
    		        console.log($holder)
    			}		
    		});
    });
    #reorder is a submit button so I want to prevent the default action and then do the POST and reload with JS (This is because I want to use a modal confirm which I haven't put in yet)

    Anyway, it seems to be aborting the AJAX POST halfway through and jumping straight to the reload, I have inspected the network tab in various browsers and what I'm typically seeing is the POST appearing for a split second and then vanishing.

    It works fine without JS, and I am testing for this with my php script. The script doesn't even acknowledge receipt of the POST variable with JS switched on. Does anyone know what is happening??
    "Persistence is the path to perfection"

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Worked fine for me, hope you don't mind but now you have one item in your list

  3. #3
    SitePoint Evangelist silversurfer5150's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hey no worries,

    Fixed it now! thanks
    "Persistence is the path to perfection"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •