0

I am getting some values from html ul elements like this

function myFunction() {
    var values =[];
    $('#sortable2').each(function(){ // id of ul
        var li = $(this).find('li')//get each li in ul
        var res = li.text().split("::");
        console.log(res)//get text of each li
    })
}

Now I want to get the res values in php variables I am trying this but it is not working

function myFunction() {
    var values =[];
    $('#sortable2').each(function(){ // id of ul
        var li = $(this).find('li')//get each li in ul
        var res = li.text().split("::");
        <?php
            $arr = res;
            echo "alert('$arr')";
        ?>
        console.log(res) //get text of each li
    })
}

Please tell me where I am going wrong.

2
  • 1
    To send variables from JS to PHP you need to use AJAX. Commented Apr 4, 2016 at 10:21
  • php runs at server and js runs at browser, very late.....! so either use ajax or submit a form. Commented Apr 4, 2016 at 10:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.