Ajax and custom parameters - passing an array

Ajax and custom parameters - passing an array

op2op2op2op2op2op2 Posts: 3Questions: 1Answers: 0
edited December 2014 in Free community support

Hi, I'm a noob with php, java, and so on.
I am trying to get data from several tables in my mysql server. Also, I want not to change or prepare several "server_processing.php" files, so I'm trying to use Custom HTTP variables.

As an example:

ajax: {
    url: "server_processing.php",
    data: {
           "tabla": "sms",
           "key": "id",
           "columnas": "{'col1','col2','col3'}"
    }
}

But my question is about: how could I pass an array to server_processing.php ?

I want to pass the table name, primary Key and columns to show. The number of columns to show is not fixed between tables, so I have to pass an array, haven't I ?

Best regards,

Answers

  • mauriciosouzamauriciosouza Posts: 4Questions: 0Answers: 0
    edited December 2014
    "ajax": {
    "url" : "transactions.php", 
    "type": "POST",
    "data" : {"cmd" : "refresh",
                  "from": $("#from-date")+" "+$("#from-time").val(),
                  "to"  : $("#to-date").val()+" "+$("#to-time").val()
    }
    

    does not work ?

  • mauriciosouzamauriciosouza Posts: 4Questions: 0Answers: 0
    edited December 2014
    var dataObject = { routeID: routeID,
                       custID:  custID,
                       stopnumber: stopnumber
                       customer: customer,
                       latitude: lat,
                       longitute: lng,
                       timestamp: timeStamp};
    
    
    "ajax": {
    "url" : "transactions.php",
    "type": "POST",
    "data" :dataObject
    }
    
    
  • op2op2op2op2op2op2 Posts: 3Questions: 1Answers: 0

    Hi mauriciosouza,

    Thanks a lot for your comment. In my humble opinion I think that the first one is not what I am asking for, the second one is like a struct, isn't it ?

    I need to pass a variable length array. I mean, one time I will request two columns from a table, and in another part of my web page, I will request four columns from another table.

    I can pass the table name as a parameter, but I DON'T KNOW how to pass the names of the columns.

    I could use the table name with a switch case to know what columns I need, but sometimes I also need to retrieve diferents columns from same table. I also think that will be better to pass columns as a parameter rather than use a switch case.

    I don't know if you understand me. My english an knowledge of php and javascript is very poor.

    I hope your answer,

    best regards,

  • op2op2op2op2op2op2 Posts: 3Questions: 1Answers: 0

    Anybody ?

This discussion has been closed.