Solved

passing a parameter to php and runs the php

Posted on 2014-03-13
4
556 Views
Last Modified: 2014-03-13
Hi,

$(td).click and ajax combination runs the php with the passed parameter, and then return the result from the php, this works perfect in some of my cases. But I need to send the parameter and runs the php and displays the php page result in a new tab in the browser, not in the same page where the ajax is called. the php page have many echos and create a webpage, but needs some parameters that are received from the ajax, like $(this).html(). How i can do that?
0
Comment
Question by:joyacv2
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39927226
$("td").click(function() {
      var p = encodeURIComponent( $(this).html() );
      window.open("/newtaburl.php?you_dont_need_ajax_param="+p,"_blank"); // $_GET or $_REQUEST
});

Open in new window

0
 
LVL 1

Author Comment

by:joyacv2
ID: 39927329
hi, is possible to do with post?
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 500 total points
ID: 39927365
$("td").click(function() {
      var p = encodeURIComponent( $(this).html() );
      var key = "key" + new Date().getTime();
      var data = { "param":p, "key":key };
      var url = "/save_this_inside_a_SESSION_for_this_key.php";
      var success = function() {
              window.open("/newtaburl.php?key="+key,"_blank");
      };
      $.post(url, data, success);
});

Open in new window


<?php
session_start();
$_SESSION[ $_POST["key"] ] = $_POST["param"];
echo "ok";
?>

Open in new window

0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 39927493
excellent!!!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now