Im trying to do something very simple and its not working. I want to run a jquery post() and retrieve the html from the file the posting too. My jquery is $.ajax({ url: 'test.php', success: function(data) { alert('Load was performed.'+data); } }); Code (markup): The test.php file just has a simple <h1>this is a test</h1> Code (markup): . When i go to run the script though no data is returned.
Hi, your code looks ok. I would also attach an error handler see if that is triggered Maybe you can also try the $.load or $.get functions insted of $.ajax see if that works kindest regards, John
Hi, you have to echo data inside your php script to be able to see it: file test.php <?php echo "<h1>this is a test</h1>";?> PHP: Regards
no? <h1>foo</h1> <?PHP echo "<h1>goo again</h1>"; PHP: this would render it twice, the .php is treated as html when not after an open <? tag hence the problem is something else. look at the console in firebug to monitor the request and expand the response, make sure the right filepath/file gets called.
it doesn't matter if you echo the HTML from PHP or you write it directly in the file, AJAX should receive the end result so HTML