0

having a bit of an issue with sending a jQuery array to a PHP file. I've looked at similar questions on here, but mine has other elements to the data variable being sent. Here's the code:

var data = 'type='+e+'&offset=' + all_dates_offset + '&filters=' + filters;
$.ajax({
    url: "pos_jobs.php", 
    type: "POST", 
    cache: false,
    data:data,
    dataType:"json",
    success: function(html){
        //Do Something
    }
});

For the data, 'e' and 'all_dates_offset' are standard variables, whereas 'filters' is an array. On the PHP side of things, I was hoping I could just use something like $_POST['filters'][0], but that is returning a null value.

Any ideas?

Thanks.

3
  • 1
    data: {type: e, offset: all_dates_offset, filters: filters}, Commented Feb 5, 2013 at 12:27
  • Follow what David has mentioned above and also refer this link's Example section first example to adopt better way to pass data. Commented Feb 5, 2013 at 12:29
  • and for the tip @BhavikShah Commented Feb 5, 2013 at 12:33

2 Answers 2

1
$.ajax({
    url: "pos_jobs.php", 
    type: "POST", 
    data: {type: e, offset: all_dates_offset, filters: filters},
    dataType:"json"
}).done(function(data) {
    //do something
});
Sign up to request clarification or add additional context in comments.

1 Comment

So simple, thanks @adeneo. I'll accept this as soon as I can.
0

use below

$.ajax({ url: "pos_jobs.php", type: "POST", cache: false, data:{'type':e,'offset':all_dates_offset,'filters':filters}, dataType:"json", success: function(html){ //Do Something } });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.