开发者

distinct and grab data while receiving it in php

开发者 https://www.devze.com 2023-03-15 09:15 出处:网络
i have a jquery script wich send a get var with id to a page开发者_如何学Go named ajaxprocess,php each time a specific element is clicked . i have 20 elements.

i have a jquery script wich send a get var with id to a page开发者_如何学Go named ajaxprocess,php each time a specific element is clicked . i have 20 elements.

the idea is create a temp table with 3 field , each time element is clicked it stores its value in field 1 , second in field 2 and third in field 3 and stop , i just want to get 3 ids stored .

here is the code. the jQuery('#test').text(data); is to test if vars were sent. the elements are all like this : .

$(document).ready(function() {
    $(".element").click(function() {
        var path = $(this).attr('id');
        $.get('ajaxprocess.php', {
            Path: path
        }, function(data) {
            $('#test').text(data);
        });
    });
});

i tried to make a count but no success. well i get perfect the first value sent when i click on an element . i want to grab this value on the database. then when i click on the second element i want to grab this second value to a second field until the third one. how can i make this ? please help


You can setup an ajax queue using this plugin for example : http://code.google.com/p/jquery-ajaxq/ That ensures the request will get responses in the correct order.

Alternatively you can add a counter in your script, that's sent accross each request :

$.get('ajaxprocess.php', {
        Path: path,
        Fieldnum: fieldnum
    }, function(data) {
        $('#test').text(data);
    });

fieldnum++;

0

精彩评论

暂无评论...
验证码 换一张
取 消