ajax is not working with chrome

Hi have this problem

I have a form with a lot checkboxes
<input value="" class="uniform" onclick="checa_campos(this)" name="4111511155" id="4111511155" type="checkbox">

Open in new window


In firefox when the user made a click over the checkbox it call the function checa_campos
<SCRIPT language=JavaScript><!--
 var participante = 10;
	 var edicion= 1;
	 var evento= 1234;


function checa_campos(campo)
{
 var temp = campo.id;
 $('#'+temp).change(function () {
            if ($('#'+temp).is(':checked')) 
			{
			    $.ajax({
                    url: "acc_act.php",
                    data: { actividad: temp, accion: 1, edicion: edicion, evento: evento, participante: participante, categoria: "Empresas" },
                    dataType: "json"
                });
            }
            else
			{
                $.ajax({
                    url: "acc_act.php",
                    data: { actividad: temp, accion: 2, edicion: edicion, evento: evento, participante: participante, categoria: "Empresas" },
                    dataType: "json"
                });
            }
});	
}
//-->
</script>

Open in new window


And using ajax call the php file "acc_act.php" where using the variables that I send, it mades some actions in a database.

This code works perfectly in Firefox, but when I tried to use it in chrome it fails.

What Im doing wrong?
altariamx2003Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
perhaps Chrome is handling the post in a different way than Firefox.

Can you try this
<SCRIPT language=JavaScript><!--
	var participante = 10;
	var edicion= 1;
	var evento= 1234;

	function checa_campos(campo)
	{
		var temp = campo.id;

		$('#'+temp).change(function () {
            if ($('#'+temp).is(':checked')) 
			{
				$.ajax({
                    url: "acc_act.php",
                    data: JSON.stringify({ "actividad": temp, "accion": 1, "edicion": edicion, "evento": evento, "participante": participante, "categoria": "Empresas" }),
                    dataType: "json"
                });
            }
            else
			{
                $.ajax({
                    url: "acc_act.php",
                    data: JSON.stringify({ "actividad": temp, "accion": 2, "edicion": edicion, "evento": evento, "participante": participante, "categoria": "Empresas" },
                    dataType: "json"
                });
            }
		});	
	}
//-->
</script>

Open in new window

The main idea is to serialize your JSON object as string using
JSON.stringify({...})

HTH
Rainer
altariamx2003Author Commented:
didnt work rainer
altariamx2003Author Commented:
Ok I found the solution

I honestly dont know why, but with this change the code works on chrome:

function checa_campos(campo)
{
 var temp = campo.id;
            if ($('#'+temp).is(':checked')) 
           {
	$.ajax({
                    url: "acc_act.php",
                    data: { actividad: temp, accion: 1, edicion: edicion, evento: evento, participante: participante, categoria: "Empresas" },
                    dataType: "json"
                });
            }
            else
           {
                $.ajax({
                    url: "acc_act.php",
                    data: { actividad: temp, accion: 2, edicion: edicion, evento: evento, participante: participante, categoria: "Empresas" },
                    dataType: "json"
                });
            }	
}  

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
altariamx2003Author Commented:
this is the solution
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.