Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Need Some Advanced jQuery/PHP help…Please?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37504
    kgscott284
    Participant

    Essentially, what i am trying to do is upgrade an old app i created to use some of the great AJAX features of jquery. Example: instead of limiting the admin to creating categories one at a time which can obviously be really monotonous, I would like to convert the page so that you can dynamically add a field so you can add multiple categories at once if desired…my issue now is, how do i go about properly posting the data via php? Here is what i am working with:

    http://jsfiddle.net/pseud0cool/WVzH4/

    Keep in mind i am planning on using AJAX to post the data…Let me know if you have any ideas for improving or anything that can help at all.

    Thanks Guys!

    #100643
    xpy
    Participant

    First of all,

    var cats = $("#categoryTable tr").length;

    won’t work because if you remove one (not the last) and then add one, you will have duplicate Id’s and names… Maybe you should just do a cats++ every time you add a cat.
    Secondly, Itterate through your inputs and bulid your POST data like:


    var postData = '?';

    $("#categoryTable input[type='text']").each(
    function(i,e){

    postData+= (postData!='?'?'&':'')+$(e).attr('id')+'='+$(e).val();

    });

    ( I think)
    I’m sure there are better ways though…

    #100684
    xpy
    Participant

    I’d aggre with @traq for the array thing… You’ll have to worry for one thing less…
    anyway, in the code I suggested, you are supposed to use the variable postData to your AJAX request like this


    $.ajax({
    type: "POST",
    url: "phpPage.php",
    data: postData
    })

    then, at the phpPage.php you’ll handle your POST data…

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.