0

I need an assistance on how to transfer this value $row[COMPONENT] in my class1.php into another page process_class.php with jQuery using post method.

i did this but it seems doesnt work ,

 $('.cuttingCheckbox').change(function() { 
 if (this.checked) { 
 $.post('process_class.php', 
 { comp : $($row[COMPONENT]).val(), comp_id : $($row[ID]).val() },
 function(response) { 
 this.setAttribute("disabled", true), alert(comp,comp_id); }); 
 } 
});

Does anyone willing to help me ?

NoobEditor
16k20 gold badges85 silver badges117 bronze badges
asked Apr 14, 2014 at 6:58
5
  • you would need ajax for that. api.jquery.com/jQuery.ajax Commented Apr 14, 2014 at 7:01
  • You can also save it into session and catch it back in another php file. it doesnot have to be form.. Commented Apr 14, 2014 at 7:03
  • i did this but it seems doesnt work , $('.cuttingCheckbox').change(function() { if (this.checked) { $.post('process_class.php', { comp : $($row[COMPONENT]).val(), comp_id : $($row[ID]).val() }, function(response){ this.setAttribute("disabled", true), alert(comp,comp_id); }); } }); Commented Apr 14, 2014 at 7:03
  • @doniyor I already have the variable like this, $row[COMPONENT]. would that possible to save this in a session ? This variable dynamically changes as the database changes Commented Apr 14, 2014 at 7:07
  • @Chriskonz, sure this is possible. i will show you in a second how to do this Commented Apr 14, 2014 at 10:39

1 Answer 1

1

you can save that $row[COMPONENT] into session like this:

$_SESSION['row_component'] = $row[COMPONENT];

and in your next page, you just retrieve it:

$row = $_SESSION['row_component'];

As Jonast said (thanks dude), you should initiate the session first at the top of your php file: session_start();

answered Apr 14, 2014 at 10:47
Sign up to request clarification or add additional context in comments.

2 Comments

Message to OP: Make sure you got session_start(); at the top of every PHP page so that sessions will work. (It must appear before any output is sent to the browser from the server). That is, if you use this approach, which you should.
@doniyor This is my implementation. and it still doesnt work even the alert... pastebin.com/mSVbF0fv pastebin.com/RS6Y1Ac3

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.