0

Sorry it was a mistake to post a question about making a condition to checkbox earlier without further investigation. It seems i need to pass my variables here

function setsession(sessionid,action, data){
        $("#totalselection").show();
        $.ajax({
            type:'POST',
            url:'test.php',
            data:'sBorrow='+sessionid+'&action='+action,
            cache:false,
            success:function(data){
                var out = "<p align='center' style='text-decoration:none;color:white;'>Total Selection: "+data+"<br/>Click here to submit your request&nbsp;<a href='borrowform.php?subid=borrow' id='submitborrow' name='submitborrow' style='text-align:center;'><input type='button' value='REQUEST' id='submitborrow' name='submitborrow'></a>&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;Click here to clear the selection <a href='#' style='text-align:center;'><input type='button' value='CLEAR'></a></p>";

                datachecked(data, this.indexValue);

                $("#totalselection").html(out)
            }
        });
    }

to the DOM of other php page. NOT TO THIS URL. It was different page. Im still not clear to this ajax and i know that ajax can only send to 1 url only. However i want the data value that this ajax hold to put it inside my php echo and make if else statement using that data. Should i create one more ajax? or else? How to send data from success to my php page and received it?

3
  • 5
    I don't understand what you're trying to ask Commented Aug 4, 2016 at 4:13
  • Do you wish go get a value stored withing the webclients DOM and send it to the server? Commented Aug 4, 2016 at 4:16
  • if you want to redirect to another page after the ajax i complete why do ajax at all ? Commented Aug 4, 2016 at 4:28

2 Answers 2

1

I think you are asking how to send your variable in ajax call. Try this simple syntax of jquery ajax call by which you can send any number of variables.

$.ajax({
    url : 'process.php',
    method: 'post',
    data : {
        var1 : val1,
        var2 : val2

        // by this way you can send multiple variable
    },
    success : function(response){
        alert(response)
    }
});

process.php:

$val1 = $_REQUEST['var1'];
$val2 = $_REQUEST['var2'];

// use it in your own way
Sign up to request clarification or add additional context in comments.

2 Comments

i can understand your technique. Just 1 thing. If the url is not process.php but we intend to send the variable in other php. It wont work right. Unless we create new ajax for that specific url.
Change the "process.php" as your requirement
0
$("document").ready(function () {
            data = {
                'name':'ys',
                'surname':'ysss',
                'pass':'123456',
                'number':5
            };
            $.post('content.php',data,function(response,status){
                if(status == 'success'){
                    $("#information").html(response);
                }
            });

you can send data as long as possible by writing to the 'data'

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.