How to send $_POST[var] to ssp by ajax
How to send $_POST[var] to ssp by ajax
i have an ajax issue and hope somebody can help.
my POST Vars does not appear within the ssp file. whats wrong ?
// 1) Datatable Editor
var thisDataTable = $('table.editorTable').DataTable({
ajax: {
url: 'my-ssp.php',
type: 'POST',
data: {
'pdoField' : 'webx_idn',
'webx_idn' : 'domain.com',
}
},
// 2) my-ssp.php
// this works!
->where('webx_idn', 'domain.com')
// doesn't work !!! a system error has occurred
// Chrome XHR Log "Undefined index: pdoField"
->where($_POST['pdoField'], $_POST['webx_idn'])
This discussion has been closed.
Answers
That looks like it should work! Perhaps you could try:
i.e. using it as a function instead. If that doesn't solve it, could you give me a link to a test case showing the issue?
One thing - you must sanitise the
pdoField
that is being submitted from the client-side. Make sure it is one of the column names you are expecting, otherwise you leave yourself open to an SQL injection attack!Allan
Alan. No its doesn't work either. How can i give you test case ?
https://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read#latest
thx tangerine. how can i show a testcase where an -ssp.php file ist included.
like:
ajax: 'path-to-ssp.php'
A link to the page would be helpful, so we could confirm the values are being passed. Or if you could post that here, that would also be helpful,
Colin
thx colin for your help. would be so great, if we can solve this problem. this is an shortened example:
the ssp-File
the table File
Here is a little example: http://live.datatables.net/kedemidu/1/edit . Our
post.php
script doesn't use those parameters, but I can see them being sent in the network inspector:Does it not work when you first load the data? Or does it work then and not when you are performing editing actions? I'm guessing the latter. Your Editor code isn't sending the extra POST parameters. Try:
in your Editor initialisation.
Allan
@allan. as you mentioned: the error occurs when editing something. with chrome inspaector i can see XHR (in the ssp file):
it so frustrating. i don't get it and i spend tons of hours for this now. maybe this tell you something.
when i print the POST in the ssp file, i can see the value in the chrome inspector, but get the error by datatable Editor.
ssp.php
I'm presuming you've added the code I suggested above to your Javascript Editor initialisation?
I can't understand that. Can you show me the full, unabridged file please?
Allan
allan. first of all - thx a lot for your patience and a late happy x-mas. maybe my english is confusing you.
here is the table:
http://live.datatables.net/suquzuri/1/edit
and the ssp-file
See my reply to your post on this topic here: https://datatables.net/forums/discussion/65171/if-empty-take-todays-date#latest .
Allan