0

I must be making some simple error somewhere, any help appreciated.

Associative Array

data_form[name] = value;

Action

$.ajax({
    type:       "GET",
    cache:      false,
    url:        "../pages/ajax/takeaction.php",
    data:       ({ json: JSON.stringify(data_form) }),
    success: function(data) {
        var message = "Your information has been received!";

        $('.element').html(message)
             .hide()
             .fadeIn(1500, function() {                 
                $(this).append("<br/>"+data)});
    }

});

This is what the JSON.stringify data string ends up as

{"action":"register","username":"","email":"","password":"","password2":"","max":"5000000","userfile":""}

Then my php file action

$json = $_GET["json"];

Gets it and has value

{\"action\":\"register\",\"username\":\"\",\"email\":\"\",\"password\":\"\",\"password2\":\"\",\"max\":\"5000000\",\"userfile\":\"\"}

Then try to decode and it returns nothing (using php array foreach etc)

   $array = json_decode($json, true);
Forteasics
  • 121
  • 1
  • 2
  • 10

1 Answers1

0

Do you have both jQuery and Prototype included? If so, take a look at JSON.stringify() array bizarreness with Prototype.js.

On second thought it looks less like that and more like you have magic_quotes_gpc set to On in php.ini.

Community
  • 1
  • 1
Raphael Schweikert
  • 18,244
  • 6
  • 55
  • 75