Here's my Javascript .ajax call:
$.ajax({
type: "GET",
url: "ajaxEditResume.php",
data: {"status" : "personal"},
success: function(html){
$("." + idValue).html("<input type='text' maxlength='50' placeholder='Street Address' name='street' value='" + html.street + "id='street'>");
}
});
And here's the php that gets called in that:
session_start();
include_once("common/includes/util/appleFunctions.php");
include_once("common/includes/util/resumeValues.php");
//echo $_GET['status'];
if($_GET['status'] == "personal")
{
$chars = array('"', "'");
$replace = array('"', ''');
$objective = str_replace($chars, $replace, $objective);
$array = array('street' => str_replace($chars, $replace, $street),
'city' => str_replace($chars, $replace, $city),
'state' => str_replace($chars, $replace, $state),
'zip' => str_replace($chars, $replace, $zip),
'phone' => str_replace($chars, $replace, $phone));
echo json_encode($array);
}
So what does this do? I'll walk through how I understand it so that maybe you'll pick up if I'm missing something.
First the .ajax call is made, and it uses ajaxEditResume.php and sends to it with a GET request. So in ajaxEditResume.php the $_GET variable $_GET['status'] is set as "personal".
We get in the PHP file, I get some values that are set in resumeValues.php (included at the top), do some formatting, and put them in an associative array. I encode this array into a json object and echo it thus sending it back to the .ajax call.
In this I change the html into a textbox. The value of this textbox SHOULD be whatever the street variable was from the php call. However, on my site in the textbox I see this:
undefinedid=
This is not right.
If however instead of doing the .html call in the success function and do this instead:
alert(html);
I see this on my site:
{"street":"931 Sheely St", "city":.......}
It's all correct. So the php encoding is working. All the correct data is getting sent back to the Javascript call.
So it makes me think this is wrong:
html.street
I'm doing something wrong there?
Thanks for the help! It's appreciated.
This post has been edited by eZACKe: 28 August 2011 - 07:04 PM

New Topic/Question
Reply




MultiQuote






|