Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2009, 03:53 PM   PM User | #1
snoodle
Regular Coder

 
Join Date: May 2007
Location: Manteca, CA
Posts: 219
Thanks: 4
Thanked 0 Times in 0 Posts
snoodle is an unknown quantity at this point
Ajax - returning PHP file contents

I recently had to reformat and reinstall everything from scratch. Now, the site I am building works fine on my provider's servers, but has a problem on my machine.

I am using JQuery/Javascript & PHP. It appears that upon returning from the server side PHP code, the data returned (echo'ed) is the complete contents of the php file (not the json data i'm passing out). This is happening for all ajax calls. I'm thinking this must be something in the the php.ini file, but don't know what.

A typical ajax caller and handler in my code looks like...

Code:
function jsFunction(){
	obj.item1 = "item1_input";
	obj.item2 = "item2_input";
	var dataString = $.toJSON(obj);
	alert("Before Update.....  "+dataString);
	$.post(handler.php', {data: dataString}, done_function); 
}

function done_function(res){
alert(res);
}
Using this simple php code...

PHP Code:
<?php
//     
$res json_decode($_REQUEST["data"], true);
// ...
// ... Processing and modifying contents of "data"
// ...
echo json_encode($res);
return 
1;
?>
The value returned to the done_function (res) is the actual contents (code) of the php file, not the data that was echo'ed. Is this due to a setting in php.ini? This code worked fine before the crash and works fine on my provider's server.

Last edited by snoodle; 03-20-2009 at 03:58 PM.. Reason: clarity
snoodle is offline   Reply With Quote
Old 03-20-2009, 04:02 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Sounds more like... there is no php server running. Are you opening the site locally with a "file:///xampplite/htdocs/whatever.php" or with a "http://localhost/whatever.php"? If the latter... is your apache (or whatever) running with php support?
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 03-20-2009, 04:21 PM   PM User | #3
snoodle
Regular Coder

 
Join Date: May 2007
Location: Manteca, CA
Posts: 219
Thanks: 4
Thanked 0 Times in 0 Posts
snoodle is an unknown quantity at this point
Yeah, phpMyAdmin isn't working either. It did at one point since that was how I imported the database from my host's server. When I try to run phpMyAdmin I get, "Cannot load mysqli extension. Please check your PHP configuration. - Documentation".

The Apache modules include php5_module. What else should I check? Should I just reinstall WAMP or... do you know how I get php back? (I'd rather learn something than just blindly try it again).
snoodle is offline   Reply With Quote
Old 03-20-2009, 04:37 PM   PM User | #4
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Remotely? Doubtful. You could always ask in the PHP forums instead, might get a better reply... or rather in the software forum, considering the question isn't related to PHP coding, but to the installation and running of Apache with PHP support.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 03-20-2009, 05:32 PM   PM User | #5
snoodle
Regular Coder

 
Join Date: May 2007
Location: Manteca, CA
Posts: 219
Thanks: 4
Thanked 0 Times in 0 Posts
snoodle is an unknown quantity at this point
Strange. I reinstalled WAMP. phpMyAdmin comes up fine but my jquery ajax calls are still returning the contents of the php file being summoned. I'm losing it.
snoodle is offline   Reply With Quote
Old 11-22-2009, 11:41 AM   PM User | #6
DaveA
New to the CF scene

 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
DaveA is an unknown quantity at this point
I had this problem too. The php script was being returned instead of the expected echoed value.

I had upgraded from php4 to php5.

The problem was caused by myself using a combination of long and short tags.

In the php.ini file for php5 'short_open_tag' was set to 'off'

The solution is either 'do not use short tags' of set 'short_open_tag' to 'on'

Hope this helps
DaveA is offline   Reply With Quote
Old 11-22-2009, 04:59 PM   PM User | #7
snoodle
Regular Coder

 
Join Date: May 2007
Location: Manteca, CA
Posts: 219
Thanks: 4
Thanked 0 Times in 0 Posts
snoodle is an unknown quantity at this point
it's been so long i forgot how i solved the problem. i know i've run into the tag problem at least once before. anyway, thanks for the reply.
snoodle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:37 AM.


Advertisement
Log in to turn off these ads.