Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:45:10+00:00 2026-06-14T07:45:10+00:00

i want to send an array to php via Ajax Json, but i cant

  • 0

i want to send an array to php via Ajax Json, but i cant do it, when i send it all i get on my server side is a csv string,

here is my jquery code where i create my array

$('#guardar_curso').click(function(){
    var respuestas = new Array();

    var a = 0;
    var b = 0;
    var c = 0;

    var last_hidden = $('body').find('input[type="hidden"]').filter(':last');
    last_hidden = parseInt(last_hidden.val()) + 1;
    var count = 0;
    for(var a = 0; a<last_hidden; a++){
        for(var b = 0; b<4; b++){

            c = $('body').find('input[name="resp['+ a +']['+ b +']"]').val();
                if(c == ''){
                    respuestas[count] = c; //ignore this

                }else{
                    respuestas[count] = c; 
                }
            count++;
            }
        }

and this next is my jquery code where is my Ajax call triggered from a submit button:

                $.ajax({
                        type:"POST",
                        url:CI.base_url + 'admin/guardar_curso',
                        data: curso_data + '&respuestas=' + respuestas,
                        dataType:"json",
                        success:function(response){
                            $.each(response, function(key, value){
                                salida = salida + value + "\n";
                            })  

curso_data is my serialized data and “respuestas” is my array

it’s just part of my code, i hope it helps make my point

any help i can get plz, this has been driving me nuts for hours, i want to loop that array with a foreach loop in php, thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:45:11+00:00Added an answer on June 14, 2026 at 7:45 am

    You are tring to concatenate an array and text which doesn’t work. You could send the array as a JSON string, and decode it when it is received.

    data: curso_data + '&respuestas=' + JSON.stringify(respuestas),
    

    Then in php:

     /* convert json to php array*/
    $respuestas= json_decode($_POST['respuestas']); 
    

    A simple test in php is print_r( $respuestas) and look at the returned array in browser console

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send an array via $.ajax to a PHP Script. <?php $arrid=array("a","b","c","d","e","f");
I want to send a Javascript array to PHP using AJAX. This seems very
I want to send array from php to jquery using json. the array in
I have login form which i want to send via ajax using serialize but
i want to send a javascript array to php using jquery ajax. $.post(controllers/ajaxcalls/users.php, {
i want to send a javascript array to php using jquery ajax. $.post(controllers/ajaxcalls/users.php, {
I have an multi-dimensional array that I want to send to a PHP script
Hello Sir i want send list of data to php server i use following
I want to send an Array with image paths and captions to a PHP
I want to send data to my server via SSH. The data is image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.