1

I want to render output of php page into html div.That means in php page has lot of jquery stuff.suppose i used current jquery ajax to load a php page.It missed to load jquery document ready stuff.

How can i do that?

4
  • Please explain a bit more about the php page.. What does it return? Commented Jan 29, 2013 at 6:11
  • This question is not clear enough! Only thing I understood is "I want to render output of php page into html div". Commented Jan 29, 2013 at 6:12
  • Are you really using symfony and cakephp together? Commented Jan 29, 2013 at 6:16
  • i used jquery highchart in php page.when i run that page in separate it is working fine. when i try to render that php page using jquery ajax. It is missed to load jquery stuff on the php page.so i dint get proper chart output. Commented Jan 29, 2013 at 6:22

3 Answers 3

5

If you want to put the output of a php page to an html page using jquery and ajax. You may do this.

$(document).ready(function(){
    $("#div1").load("demo_test.php");
});

div1 is the div which is to be updated with the php content. This link may help you.

http://www.w3schools.com/jquery/jquery_ajax_intro.asp

Sign up to request clarification or add additional context in comments.

Comments

0

Here's is the short example. jQuery API Doc

html

 <div id="content"></div>
 <input type="button" id="btnLoad" value="Load" />

jquery

$("#btnLoad").click(function(){

    $.ajax({
        type: 'POST',
        url: 'page1.php',
        success: function(data){
                 if(data != null) $("#content").text(data)
         }
     });
});

page1.php

<?php

  echo "This is the sample data to be printed for request from AJAX";

 ?>

Comments

0

you can use ajax observe method

cakephp ajax helper

<?php echo $form->create( 'Post' ); ?>
<?php $titles = array( 1 => 'Tom', 2 => 'Dick', 3 => 'Harry' ); ?>  
<?php echo $form->input( 'title', array( 'options' => $titles ) ) ?>
<label for="something">This checkbox will be send (and it will trigger Ajax reqest)  </label>
<input id="something" type="checkbox" name='data[Post][something]' value='1' />
</form>

<?php
echo $ajax->observeForm( 'PostAddForm', 
    array(
        'url' => array( 'action' => 'edit' ),
        'complete' => 'alert(request.responseText)'
    ) 
); ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.