Hi everybody!
I'm building a small ajax app which consists of only 3 php files.
index.php which contains all the app and has a couple of links. When a
link is clicked an Ajax request is sent to the server (using prototype)
to the
url central.php with only one parameter 'id'. Depending on that
parameter, central.php should look for the appropiate content, in this
case link1.php.
Then I return a JSON object with the "things" that should be updated on
index.php
So this is the pseudo-code:
index.php
<html>...
<body>
<a href="" onclick="[send the Ajax request using prototype with the id =
1]>Link #1</a>
<div id="theUpdatableDIV"></div>
</body>
central.php
<html>...
<body>
<?php
[read the id parameter]
switch(id){
case 1: //which is the only case for now!!
//build the JSON object
$output = array("title" => "Link #1 Title!",
"content"=>file_get_contents("link1.php"));//here I read the last file
which has the content to be updated asynchronously
return [the JSON object based on $output];
break;
}
?>
</body>
link1.php
<div>Welcome to the content of link #1 which was updated using <a
href="ajax.org">ajax</a></div>
the JSON object is formed ok, now, my problem is that link1.php outputs
like this:
<div>Welcome to the content of link #1 which was updated using <a
href="ajax.org">ajax<\/a><\/div>
So at the moment I update the <div id="theUpdatableDIV"> element on
index.php, I get no "real" content, but a string with the
strange slashes.
I've tried:
stripslashes, ereg_replace, str_replace and strtr to eliminate the
wierd slashes.
Can anybody tell how to do it right?
Thank you!
Balpo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php