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
    zto
    zto is offline
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AJAX-mysql-multiple queries

    greetings,

    i'm quite new in javascript programming and just started feeling more comfrotable with AJAX

    I have a question for you

    i have a page in which:
    - i get data from mysql and present them on screen
    - I insert data in mysql
    - delete data from mysql

    my question is which is the best way to implement those operation useing ajax and php

    should i have 3 completely different ajax functions? should i have one and change only the .php i send data to?
    or should i have one function and pass all the data with the appropriate flags to one .php file which will choose which function to use?

    i hope you understand what i mean
    sorry for my bad english

    thnx
    giorgos

  • #2
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Generally speaking, you should use GET requests to retrieve data from the server, and POST requests to send data to the server. Based on that general rule, I'd probably create an object with three methods, all using the same XMLHttpRequest object to perform different tasks, maybe a generic GET method that can be altered based on what's passed to it (either a record ID value to delete, or null). Whether or not you use multiple PHP scripts to handle each request is up to you.

  • #3
    zto
    zto is offline
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bdl View Post
    Generally speaking, you should use GET requests to retrieve data from the server, and POST requests to send data to the server.
    why that? are there security problems when using GET to retrieve and send data to the server?

  • #4
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Quote Originally Posted by zto View Post
    why that? are there security problems when using GET to retrieve and send data to the server?
    Not really anymore than a POST request. It's just logical; an HTTP GET request is "getting" data from the server. You're not changing anything. An HTTP POST request is "posting" data to the server, so you're actually modifying something on the server, e.g. inserting or updating a database record. Aside from that, a GET request sends data right over the URI, and you probably don't want that when performing an insert or update. Since this is the case, technically it's not as secure as using POST, because all the server logs will contain any data you're inserting; not a huge deal, but for security conscious individuals it may matter.

    Google search : HTTP POST vs GET
    Methos GET and POST


  •  

    Posting Permissions

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