Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ajax - Handling process scripts

    I understand how ajax sends a request to a server side script and how it gets a response.

    A lot of my scripts are usually "process" scripts and follow this flow:

    user_interface.php (form leads to process script)
    process_data.php (script that processes form into database...)
    user_interface.php (back to user_interface via header() in proccess_data.php)

    I do this to keep file sizes down.

    Anyway how would I go about getting ajax to handle that kind of a script? Do I need to rewrite my scripts to be included as apposed to separate files that redirect? I am also trying to keep graceful degradation in mind.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    What are you using the AJAX call for? The path to the server-side script that the AJAX code uses doesn't really matter.. just point it to the page that you're using to process the AJAX request.

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    The only (good) peaceful degradation that I know of is to have Javascript intercept a normal form submission, and AJAX the form instead. But in some cases it's not really worth the time to have two methods.

    Basically what you would have to do is write a javascript function to go through all of the forms elements and build a GET style URL with the data, (though use POST on large forms.) This can be complicated for people who don't know Javascript well because you run into select menus, and worse yet, radios and checkboxes. They aren't as simple a normal input.

    Also know that you can't upload files through AJAX.

    If you are trying to get a form to save to a database or session as the user fills it out for whatever reason, then AJAX is a good idea, but if your just trying to stop the page flicker during a normal page submission, its probably not worth your time.
    If I'm postin here, I NEED YOUR HELP!!

  • #4
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Ultragames View Post
    Also know that you can't upload files through AJAX.
    Just thought i would point out that you could mimic Ajax when uploading files by using iframes. Once the iframe is finished uploading the file(s), you may refresh the container by calling the parent from with in the iframe.


  •  

    Posting Permissions

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