I’m trying to pass a collection of parameters to a PHP page to be processed, from a JavaScript function:
entries: "test data from JavaScript"
In my PHP page I’m trying to grab the value that was posted back to the page:
$_POST['entries']
but this keeps return ’emtpy’, regardless of what I try to push through. I’m new to PHP so this might be a stupid thing to fix.
This is invoked from a button click like such:
$("#submitButton").click(function(){});
Should the be wrapped in a form, as I don’t see the need for this?
Update [full code]
var proxy = new ServiceProxy("submit.php");
$("#submit").click(function () {
var store = $("#store_name").val();
var contact = $("#contact_person").val();
proxy.invoke("", { entries: store }, success, error, false);
return false;
});
Note on the ServiceProxy. This proxy class wraps the default $.ajax {…} into a neat little proxy class, thanks to Rick Strahl over at west-wind. I’ve used this proxy class successfully in numerous single HTML and ASP.Net solutions in the past, so I don’t it’s the proxy service that’s causing the issue.
Looks like your using jQuery, so why not use their post function?
$.post(“/file/location/post.php”, { Name: “Hello”, Email: “email@address.com” } );
Then in your php code you can use:
$_POST[‘Name’] and $_POST[‘Email’]
Hope this helps.
Sorry, just seen your updated code – this should work: