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.

Ajax inside ajax help

Discussion in 'JavaScript' started by joesgraphics, Feb 27, 2007.

  1. #1
    Hi does any of you no the hack so you can have ajax inside ajax so like showing the page in ajax and in that page there is a form that submits using ajax.

    If you need to see the ajax code's ill post it here if you ask.

    Thanks in advanced.
     
    joesgraphics, Feb 27, 2007 IP
    DarkBrothers likes this.
  2. codeassist

    codeassist Peon

    Messages:
    267
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes that's a good question. I am currently in need of a similar solution
     
    codeassist, Feb 27, 2007 IP
  3. 3l3ctr1c

    3l3ctr1c Peon

    Messages:
    380
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Alright I have done this and works perfect!

    Let me first tell you how this works -

    index.php -><- con1.php
    (Through ajax variable "name" sent to con1.php and and is shown at div tag "results")

    Then con1.php has another form within it now this too has a field.

    index.php-><-con1.php-><-con2.php
    (Through ajax variable "name2" sent to con2.php and and is shown at div tag "results2")

    Here is the demo

    The current one leaves the content retrieved from con1.php, but if you want it can be even done as con2.php's content replaces the first ajax received content.

    The codes are a bit long to write here, therefore I've zipped them here
    http://hakc.net/ajax-in-ajax/ajax-in-ajax.zip
    Code (markup):
    I can get a tutorial too written on how this works, if you want at my blog.

    3l3ctr1c
     
    3l3ctr1c, Feb 28, 2007 IP
  4. codeassist

    codeassist Peon

    Messages:
    267
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks much man. I will try implementing following that tut.
     
    codeassist, Feb 28, 2007 IP
  5. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for you help jst downlaoded the zip file :) gona take a look at the code in a min ill tell you if i get it to work with my ajax.
     
    joesgraphics, Feb 28, 2007 IP
  6. 3l3ctr1c

    3l3ctr1c Peon

    Messages:
    380
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If it's not working, drop the code here I'll make it on.
     
    3l3ctr1c, Feb 28, 2007 IP
  7. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi this is the code im useing for my form see code here
    and the js file for the form is here.

    and for that ajax window im showing the content with the code is here to view.

    that jst useing a div like your code does :)

    I found you code very usefull for other things but im abit stuck with my form bit that i have if you have time to look and see if ther is an easyer way to do it.

    Thanks in advanced. :)
     
    joesgraphics, Feb 28, 2007 IP
  8. 3l3ctr1c

    3l3ctr1c Peon

    Messages:
    380
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I'll do that and edit this entry if possible by tommorow.

    edit : It'll be good if you make it simple like a normal non ajaxed php script that makes it easier to ajax, so if you can do that in a simple php script with say get/post It'll be easier.
     
    3l3ctr1c, Feb 28, 2007 IP
  9. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ok sure thanks :) do u want it wil just a thew imputs on and ill edit the script later for more form imputs or do you want the full form.
     
    joesgraphics, Feb 28, 2007 IP
  10. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Is this ok Iv spaced all the forms imputs away from the table so its easy to read if you want me to just put the form code there with no table bits just say and i will delete all th table code.


    <form name="settings" method="POST" action="">
    
    
    <fieldset>
    <legend><strong>Add Site</strong></legend>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Active:</td>
    <td width="75%">
    
    <select name="active" id="active"><option>True</option><option>False</option></select>
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Bid:</td>
    <td width="75%">
    
    
    <input name="bid" id="bid" type="text" value="<?php echo $_POST["bid"]; ?>" size="12">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Name:</td>
    <td width="75%">
    
    
    <input name="name" id="name" type="text" value="<?php echo $_POST["name"]; ?>">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Date:</td>
    <td width="75%">
    
    
    <input name="date" id="date" type="text" value="<?php echo date("d-M-Y"); ?>">
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Updated Date:</td>
    <td width="75%">
    
    <input name="udate" id="udate" type="text" value="<?php echo date("d-M-Y"); ?>">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Title:</td>
    <td width="75%">
    
    
    <input name="title" id="title" type="text" value="<?php echo $_POST["title"]; ?>">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Description1:</td>
    <td width="75%">
    
    
    <input name="desc1" id="desc1" type="text" value="<?php echo $_POST["desc1"]; ?>">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Description2:</td>
    <td width="75%">
    
    
    <input name="desc2" id="desc2" type="text" value="<?php echo $_POST["desc2"]; ?>">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Description3:</td>
    <td width="75%">
    
    
    <input name="desc3" id="desc3" type="text" value="<?php echo $_POST["desc3"]; ?>">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Link:</td>
    <td width="75%">
    
    
    <input name="link" id="link" type="text" value="http://">
    
    
    </td>
    </tr>
    </table>
    <table width="75%" border="0">
    <tr>
    <td width="25%">Email:</td>
    <td width="75%">
    
    
    <input name="email" id="email" type="text" value="<?php echo $_POST["email"]; ?>">
    
    
    </td>
    </tr>
    </table>
    </fieldset>
    <br />
    
    
    <input name="submit" type="submit" value="Submit" />
    
    
    &nbsp;&nbsp;
    
    
    <input name="reset" type="reset" id="reset" value="Reset">
    
    
    </form>
    
    
    HTML:
     
    joesgraphics, Feb 28, 2007 IP
  11. 3l3ctr1c

    3l3ctr1c Peon

    Messages:
    380
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #11
    alright I'm doing it, will edit this as soon as I finish.

    How exactly you want it, I don't get like the above code when submited -> add-save.php then what ?

    say the above code is index.php and it has go into add-save.php

    so the code now is like index.php-><-add-save.php

    Now what do you want the thing to do once the data is feed into add-save.php ?
     
    3l3ctr1c, Mar 1, 2007 IP
  12. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    say if there was an error or if it worked etc
     
    joesgraphics, Mar 1, 2007 IP
  13. 3l3ctr1c

    3l3ctr1c Peon

    Messages:
    380
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #13
    check your PM.
     
    3l3ctr1c, Mar 2, 2007 IP
    joesgraphics likes this.
  14. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Thanks your a (star) :) rep added only if my paypal info was updated i would of give you some money thanks for all your help.



    ANd one more thing is it possable to define a page thats in ajax and get to check if its on a page it can be viewed on e.g.

    On the ajax page you have this at the start of the page:

    if (!defined('valid')) {
      die("This page cannot be accessed directly.");
    }
    PHP:

    and on the page that it can be viewed on it has :
     define('valid', 1);
    PHP:
    Or is ther anuther way to do this to work with ajax. :)
     
    joesgraphics, Mar 2, 2007 IP
  15. 3l3ctr1c

    3l3ctr1c Peon

    Messages:
    380
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #15
    I don't get what you mean, PM me your MSN/Yahoo.

    3l3ctr1c
     
    3l3ctr1c, Mar 2, 2007 IP