1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[QUESTION] Calling PHP Page with JavaScript

Discussion in 'JavaScript' started by JeremiasRama, Oct 23, 2014.

  1. #1
    The Script
    <script>
    $(document).ready(function(){
    $("#ContactForm").load("contactus/index.php?a=add");
    });
    </script>
    Code (markup):
    The Problem
    When I'm using that script, the page is called along with the script. But, the called PHP file can't function properly because it thinks that my root is that file directory.

    Example:
    contact.html calls contactus/submit.php
    Then index.php will consider directory of contact.html to be its directory. How to solve this problem so the index.php file will function properly.
     
    Last edited by a moderator: Oct 23, 2014
    JeremiasRama, Oct 23, 2014 IP
  2. capsuletoy

    capsuletoy Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Can you use the absolute path for the php file? such as /path/to/contactus/index.php?a=add
     
    capsuletoy, Oct 23, 2014 IP
  3. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I can't figure out what you're trying to do here.. A URL with the problem in action would help.
     
    seductiveapps.com, Oct 25, 2014 IP
  4. JeremiasRama

    JeremiasRama Member

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #4
    So basically I need to place a PHP PAGE in my HTML PAGE.

    Now I'm trying to use <iframe scr="..."></iframe>
    It works. Now problem: How to maintain iframe height according to the PHP PAGE it called.

    The first iframe called a form in index.php?cs=add
    Then after submit button is clicked, the frame content changes to index.php?cs=submit with different height.

    I want it to automatically adjust height. Width is not the problem.
     
    JeremiasRama, Oct 26, 2014 IP
  5. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #5
    set <iframe src="......" style="width:100%;height:100%;"> first, see if that works.

    there's a couple of ways to solve this problem, but not all are trivial.
    - to load up your PHP content via AJAX in <body onload="ajaxCall()">, means search engines can't see the content that's provided by the PHP call.
    - to include your PHP content via php.net::eek:b_start() (and related php functions), is possible (i do this in my framework by necessity), but a bit cumbersome compared with your current solution, an iframe (which does get seen by searchengine crawler programs)
     
    seductiveapps.com, Oct 26, 2014 IP
  6. seductiveapps.com

    seductiveapps.com Active Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #6
    although, if you have the iframe set to 100% and 100%, why do you still use an iframe, and not just a plain URL pointing straight to the "inner" PHP call? :)
     
    seductiveapps.com, Oct 26, 2014 IP
  7. member8200

    member8200 Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #7
    uhmm. my thoughts exactly, why are you still using iframe. it's not a very good practice anymore in my opinion. :)
    please don't get me wrong.
     
    member8200, Nov 3, 2014 IP