0

The button:

<button id="animals" type="button" value="push" >Push</button>

I have a php array:

$animalArray = array($dog, $cat, $horse, $lamb, $fox);

This is the jquery:

$(document).ready(function() {
    $("#animals").click(function(){
        // here comes the array push something like this
        array_push($animalArray, $lion);
    }); 
});

I know the 'array_push($animalArray, $lion);' php code and not possible to run in the jquery code. I have tried session to store array, but did not work for me. I appreciate every help. Thanks.

1 Answer 1

2

You have to write a server side script with PHP (that handles the content of your array) which is then called via Ajax from within your jQuery code (on the client side). It is not possible to do this in a single script either on client side nor on server side.

Sign up to request clarification or add additional context in comments.

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.