Solved

passing a parameter to php and runs the php

Posted on 2014-03-13
4
561 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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

Suggested Solutions

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

685 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