echez
echez

Reputation: 565

Is it possible to send php variable via link to popup

How can I get this link to open as a popup perhaps with ajax?

<a href="page.php?catId=<?php $row['catId'];?>&userId=<?php $row['userId']; ?>">

With the variables transfered to the popup.

I quite like the ajax modal popup, but don't know how to pass php varaiables.

Thanks

Upvotes: 0

Views: 297

Answers (3)

salih0vicX
salih0vicX

Reputation: 1373

You can pass the link to javascript:

var myHTML= '<html>' +
'<body>' +
'<div>' + page.php?catId=<?php $row['catId'];?>&userId=<?php $row['userId']; ?> + '</div>+
'<!-- other html here -->' +
'</body>' +
'</html>';

var myPopup= window.open('http://www.domain_here.com/mypopup.html','mywindow','width=500,height=500,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0');

myPopup.document.open();
myPopup.document.write(myHTML);
myPopup.document.close();

Upvotes: 1

Viacheslav Kondratiuk
Viacheslav Kondratiuk

Reputation: 8889

Try to use jQuery and it's section called data.

$.ajax({
  type: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
}).done(function( msg ) {
  alert( "Data Saved: " + msg );
});

jQuery Ajax

Upvotes: 0

Ed Manet
Ed Manet

Reputation: 3178

In page.php, you get the query string like this:

$catId = $_GET['catId'];
$userId = $_GET['userId'];

Upvotes: 1

Related Questions