Login | Register | FAQ
Anonymous

Ajax Help!?!?!??

+ Post a reply

6 posts Page 1 of 1


Ajax Help!?!?!??

by soccerwebsitemaker » Thu Jun 07, 2012 11:30 pm

Hey, I have this code - I don't know why this code doesn't work, there are no errors (according to my browser Inspect Element) so can anyone help me find and resolve my problem?


JavaScript code:



Code: Select all
//AJAX STUFF

      $(document).ready(function()
      
      {
      
      $('#bluebgradio').click(function()
      
      {
      
      $.ajax(
      
      {
      
      type: "POST",
      
      url: profile.php,
      
      data: {blueBGhas: "yes"}})

      .done(function()

      {

      alert("Hello");

      });

      });

      });
User avatar

soccerwebsitemaker

  • Posts: 139
  • Joined: Sat Dec 31, 2011 6:25 pm
--
Coins. Profile. Games. Chat. Fun.

CoinAwards.

Check it out at http://www.coinawards.net63.net/

Re: Ajax Help!?!?!??

by XainPro » Fri Jun 08, 2012 11:11 am

try like this
Code: Select all
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
}
</script>
</head>
<body>

<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>

</body>
</html>

User avatar

XainPro

  • Posts: 3662
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: Ajax Help!?!?!??

by XainPro » Fri Jun 08, 2012 11:14 am

in the place of
ajax_info.txt you should use the file name of your php script like you use in
<form action="ajax_info.txt" method="get" />
User avatar

XainPro

  • Posts: 3662
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: Ajax Help!?!?!??

by soccerwebsitemaker » Fri Jun 08, 2012 12:55 pm

But that is just displaying stuff from another place.

How do I send stuff using the code I had?

I need to send data to a url: profile.php

Will my code do that correctly?
User avatar

soccerwebsitemaker

  • Posts: 139
  • Joined: Sat Dec 31, 2011 6:25 pm
--
Coins. Profile. Games. Chat. Fun.

CoinAwards.

Check it out at http://www.coinawards.net63.net/

Re: Ajax Help!?!?!??

by soccerwebsitemaker » Fri Jun 08, 2012 3:10 pm

Never mind, a different code help site figured out the problem for me:

I needed to put quotes around profile.php...

Thanks anyway
User avatar

soccerwebsitemaker

  • Posts: 139
  • Joined: Sat Dec 31, 2011 6:25 pm
--
Coins. Profile. Games. Chat. Fun.

CoinAwards.

Check it out at http://www.coinawards.net63.net/

Re: Ajax Help!?!?!??

by XainPro » Sat Jun 09, 2012 6:09 am

ok glad you did it..
User avatar

XainPro

  • Posts: 3662
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1