April 30, 2012

How do I pass a javascript variable to php and reload a frame

Question by bisslad

Ok this may sound a little weird but what i have is a frameset generated by php with codeigniter framework.

In one frame i am displaying rows of database query results with links attached to the row index of each record.

What I want to happen, is that you click one of the links and it brings up a more detailed summary of the record in the right hand frame.

While I am aware of the fact that php is server side etc. i was trying to make the link reload the right hand frame with the value of the index from the left hand side, then within the controller i can query the database using the index and push back the same summary page with the full record.

Answer by Starx

You need to send an AJAX request to the server with the variable. You can google on How to send ajax request to server.

However, Here is a simple example of this, using jQuery

$.post("/next/page", {
   'variable1' : 'value1'
}, function(data) {
   //on success handler

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+


Please fill the form - I will response as fast as I can!