0
$("#doStatus").click(function()
{
var serialized = $("#formStatus").serialize() 
 $.get("<?echo $site['url'];?>modules/yobilab/tuitting_core/classes/doStatusBox.php", serialized);
window.setTimeout('location.reload()', 1000);
return false;
});

This code will return something like this:

tuitting=test&f%5B%5D=2&f%5B%5D=4&f%5B%5D=8&t%5B%5D=2&t%5B%5D=3&t%5B%5D=4

Where tuitting(the first value) is the value of the textarea, then we have:

-f this is the name of somecheckboxes that have the same names but different values

-t other checkboxes, same names, different values

As you may see the serialized function for "f" and "t" returns strange values, when they should only be simple number, like tuitting=test&f=1&f=3&t=9&t=10

Now when the ajax call the doStatusBox.php file nothing happens.

The doStatusBox.php file is made by a simple foreach php loop.

It will take the below variables:

$_GET['tuitting']
$_GET['t']
$_GET['f']

Foreach `$_GET['t'] and $_GET['f'] the loop will insert the relative values into the database.

This is not working at all. The php foreach can not recognize the results given by the jQuery serialize function and does not do simply anything.

What is the problem?

I should use another function instead of foreach?

Or the problem is in the jQuery serialized function?

Please help me. `

4
  • could you post some markup from the page and a var_dump of the $_GET from the php script pleeze... Commented May 20, 2011 at 11:35
  • Can you please post a var_dump of $_GET? Commented May 20, 2011 at 11:35
  • Ciao Nicola..che cosa è var_dump? What is var_dump? Commented May 20, 2011 at 11:37
  • us3.php.net/manual/en/function.var-dump.php -- critical debugging tool. Commented May 20, 2011 at 12:40

1 Answer 1

1

Since we cannot see your HTML code, I can't say for sure what the problem is, but I suspect it's one of two problems:

  1. (most likely) - your checkbox fields need to have a [] after the name. Example: name="t[]". If all of your checkboxes are name="t", then when multiple are posted, PHP will only see one of them. However, if you put brackets at the end of the name PHP will recognize the collection of values as an array that you can loop through.

  2. (less likely) - the PHP script that receives this data should run urldecode() on the data. Example: $tuitting = urldecode($_GET['tuitting']);

Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.