Reputation: 11
Alright, so here is the code that I am calling from within the js file: (Yes, I know it's PHP code; My site handles js files as php with .htaccess, and then sends the appropriate content-type header to the browser to handle it at the end. I.E content-type: application/javascript)
<?php
if (count($_GET)>0) {
print_r($_GET);
while(list($key, $value) = each($_GET)) {
echo $key." - ".$value."\n";
}
} else {
echo "alert('no get?');";
}
?>
My problem is this:
It outputs the array from print_r correctly, I.E:
Array
(
[name%3A1] =>
[call_id] => 0
[_] => 1339598074533
)
But, it refuses to use the while(list($key, $index) = each($_GET))
Any ideas why I can't go through the $_GET
var? Maybe I typed something wrong?
The url that the ajax request sends to is: http://preview.tinyurl.com/bnpe8fe
Also, it seems every time I use post as the type, instead of get, it doesn't send the post data correctly (it doesn't send it at all);
Is there any way to use POST
data with an ajax request to a js file instead of GET
?
Upvotes: 1
Views: 683
Reputation: 3526
Why not use foreach
? e.g.
foreach ($_GET as $key => $value) {
...
}
Upvotes: 3