Hello Everyone, I`m Using this code to pass javascript associative array to php using jquery ajax
function install (loc) {
var mydata = [];
//lightbox();
switch(loc){
case "step1":
{
mydata['step'] = '1';
mydata['SiteName'] = $("#siteName").val();
mydata['SiteDesc'] = $("#siteDesc").val();
mydata['AdminEmail'] = $("#adminEmail").val();
mydata['username'] = $("#username").val();
mydata['password'] = $("#password").val();
}
break;
case "step2":
{
mydata = [];
}
break;
case "step3":
{
mydata = [];
}
break;
case "step4":
{
mydata = [];
}
break;
default : "error";
}
$.ajax({
type: 'POST',
url: 'install.php',
data: {
DataArray:mydata
},
dataType:'html',
success: function (data) {
$("#popupMSG").html(data);
},
error:function (data){
}
});
}
in install.php I`m doing this test
<?php
$result = $_POST['DataArray'];
echo $result[0];
?>
but I get error :
Notice: Undefined index: DataArray in C:\wamp\www\Tests\test1\installation\install.php on line 2
whats wrong with this code ? can anyone help?