Announcement

Collapse
No announcement yet.

[SOLVED] Accessing post variables in a blank application

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] Accessing post variables in a blank application

    How do I read the POSTed (from another application) variable within a blank application?

    I tried both:
    • [posted_var] (defined as a POST\GET incoming variable in Application\Global variables)
    • $_POST['posted_var']
    but to no avail.

  • #2
    $_POST['posted_var'] is the way if you are calling from an external non sc app.

    Are you sure you are receiving the var in POST? Did you looked to headers and make sure?
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      Giu,

      in a grid I have a JS script, triggerd by an onclick event, that POSTs to a blank app ("getp" in the code below) via AJAX:

      Code:
      GRID
      xmlhttp.open("POST","../getp",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("idacc=21");
      BLANK
      $id = $_POST['idacc']; echo $id;
      And all I get echoed is an "Undefined index: idacc" error.

      But if I change the code just to use GET instead:
      Code:
      GRID
      xmlhttp.open("GET","../getp?idacc=21",true); xmlhttp.send();
      BLANK
      $id = $_GET['idacc']; echo $id;
      it works.

      So where's the error in the POST version??

      Comment


      • #4
        Because you are not calling correctly. You have to use complete url. I'm sure you are getting a warning on console about this.

        xmlhttp.open("POST","../getp",true);

        should be

        xmlhttp.open("POST","../getp/index.php",true) or xmlhttp.open("POST","../getp/getp.php",true) don't remember exactly
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment


        • #5
          Giu,

          thanks a lot!

          Either "../getp/index.php" or "../getp/get.php" can be used and the $_POST variable is accessible.

          Comment

          Working...
          X