Reputation: 115
I'm trying to send data via POST to PHP file.. $.get() - works fine, hovewer I couldn't tell the same about $.post() or $.ajax() with method post.. Here my code I wrote:
$('[name="update"]').click(function(){
tr = $(this).parents('tr');
u = [];
u["username"] = tr.find('[name="u[username]"]').val();
u["display_name"] = tr.find('[name="u[display_name]"]').val();
u["type"] = tr.find('[name="u[type]"]').val();
$.ajax({
type: "POST",
url: "../ajax-queries/update-user.php",
data: {update:u},
cache: false,
success: function(data){
alert(data);
}
});
});
And PHP file looks like:
<?php
print_r($_POST);
?>
Response I get:
Array(
)
Using latest jQuery lib... no ideas why not working.. any solutions you can offer? Is that could be posible because of port:2014? in case i tried and in :80 (same results)..
Upvotes: 0
Views: 83
Reputation: 13267
Array with key index is not an array, it's an object, try alert(typeof u). sending an array with key index will fail in IE8.
Upvotes: 0
Reputation: 1496
Because you aren't setting anything.
Try changing u to {}
, like: u = {};
Upvotes: 1