DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: Multiple simultaneous Ajax requests with Tokens

  1. #1
    Join Date
    Mar 2009

    Question Multiple simultaneous Ajax requests with Tokens

    What I'm trying to do is make a column of DIVs that each onclick will use ajax to obtain unique that will then be inserted into another corresponding DIV.
    This part is fine, but I want to eliminate the possibility of Cross-Site Request Forgery. I know I need to use tokens, but I'm not sure how to implement it. Since requests could potentially be made simultaneously, would I have to use a unique token for each one?

    I'm expecting to have hundreds of DIVs on the page that can make a request, so giving each one a hidden token could affect the size of the page.

    To give you an idea of what I'm trying to do, I'm just going to post some code and attach an image as a visual aid. (I'm using JQuery):

    function getanswer(id,num1,num2){
    	var token = document.getElementById('token').value;
    	$.post("addnumbers.php", { id: id, num1: num1, num2: num2, token: token },
    		document.getElementById('answer_'+id).innerHTML = data;
      	}, "text");
    Then there would just be two columns of DIV's.
    Column 1:
    HTML Code:
    <div onclick='getanswer(1,2,3)'>
    2 + 3 =
    Column 2:
    HTML Code:
    <div id='answer_1'>

    Now I just need that concept to work securely.

    Just use your imagination and pretend that the simple math problem is actually top secret info...
    Attached Images Attached Images

Similar Threads

  1. Replies: 0
    Last Post: 07-30-2008, 04:27 PM
  2. Replies: 1
    Last Post: 07-08-2007, 10:53 PM
  3. Replies: 0
    Last Post: 01-15-2007, 03:30 AM
  4. New forum + some AJAX links
    By Lori in forum AJAX
    Replies: 0
    Last Post: 02-09-2006, 02:26 PM
  5. handling concurrent ajax requests
    By Latha in forum Java
    Replies: 0
    Last Post: 01-04-2006, 05:44 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center