I have resolved all issues now and it's working, thanks for all the
help! This is the code I have right now:

function ajaxAdd() {
        $('form').submit(function() {
                                   var nick = document.register.nick.value;
                                   $(':submit', this).attr('value', 
'Adding...');
                                   $(':submit', this).attr('disabled', 
'disabled');
                                   $.ajax({
                                                  type: 'GET',
                                                  url: 'data.php',
                                                  data: "nick=" + nick,
                                                  cache: false,
                                                  success: function() {
                                                          
$(':submit').removeAttr('disabled');
                                                          
$(':submit').attr('value', 'Add');
                                                          
$(':text').removeAttr('value');
                                                          
$('#status').load('output.php');
                                                          }
                                                  });
                                   return false;
                                        });
}

It posts an url like: data.php?_=124819246&nick=nick

Once again, thanks for all the help!

On May 17, 12:29 pm, Nahaz <pierre.christoffer...@gmail.com> wrote:
> I have resolved the multiplying of data error, there was some code in
> there that I thought I removed.
>
> I have uploaded the script so you can test it athttp://dev.nahaz.se
>
> On May 17, 12:13 pm, Nahaz <pierre.christoffer...@gmail.com> wrote:
>
> > Upon adding return false; to my submit function a most troublesome
> > error has appeared. When you add data, the first time 1 post is
> > inserted to the db like it should, second click though will generete 2
> > posts, third 3 posts and so on.
>
> > Also my adding and removal of the attribute "disabled" to the button
> > has stopped working correctly.
>
> > On May 15, 2:17 pm, Mike Alsup <mal...@gmail.com> wrote:
>
> > > You need to add "return false" to your submit handler.
>
> > > $('form').submit(function() {
> > >     // do ajaxy stuff
>
> > >     return false;
>
> > > });
>
> > > On May 15, 2:25 am, Nahaz <pierre.christoffer...@gmail.com> wrote:
>
> > > > I can check that, but as I said before, it works perfectly fine on my
> > > > local webserver, it's when the script is run on my webhost the issue
> > > > occurs. The database seems to be very slow there at the moment.
>
> > > > Ill check with firebug and post the results here.
>
> > > > On May 14, 9:00 pm, James <james.gp....@gmail.com> wrote:
>
> > > > > Sorry, I mean "all HTTP header data".
>
> > > > > On May 14, 9:00 am, James <james.gp....@gmail.com> wrote:
>
> > > > > > Have you tried using the Firebug add-on for Firefox to debug whether
> > > > > > theAJAXrequest was actually sent in the first place?
> > > > > > It's very helpful because it'll show you the exact URL that it
> > > > > > requests, theGET/POST data it sends, all HTTP data, and the response
> > > > > > you receive.
>
> > > > > > On May 13, 8:21 pm, Nahaz <pierre.christoffer...@gmail.com> wrote:
>
> > > > > > > Ah sorry about that.
>
> > > > > > > It doesn't cause an error, it looks like it sends data because ?
> > > > > > > nick=nick appears in your url but it does notgetinto the database
> > > > > > > somehow. If you call /data.php?nick=nick it will work, it's when 
> > > > > > > it's
> > > > > > > called via $.ajax(); that the issue occurs. I havn't confirmed 
> > > > > > > but it
> > > > > > > seems to occasionally work in IE7 but not FF or Chrome.
>
> > > > > > > I also tried to add "cache: false" and my own random generator to 
> > > > > > > the
> > > > > > > url but it won'tgetposted to the url, only the "?nick=nick" comes
> > > > > > > up.
>
> > > > > > > I will fix public access after work so you can see the problem in
> > > > > > > action.
>
> > > > > > > On May 13, 8:01 pm, James <james.gp....@gmail.com> wrote:
>
> > > > > > > > Define what "not working correctly" means.
> > > > > > > > Does it cause an error? Does the requestgetsent but nothing 
> > > > > > > > happens?
> > > > > > > > Does the requestgetsent without theGETdata? ... etc.
>
> > > > > > > > On May 12, 12:00 pm, Nahaz <pierre.christoffer...@gmail.com> 
> > > > > > > > wrote:
>
> > > > > > > > > I have this snippet:
>
> > > > > > > > > function ajaxAdd() {
> > > > > > > > >         $('form').submit(function() {
> > > > > > > > >                                    var nick = 
> > > > > > > > > document.register.nick.value;
> > > > > > > > >                                    $(':submit', 
> > > > > > > > > this).attr('value', 'Adding...');
> > > > > > > > >                                    $(':submit', 
> > > > > > > > > this).attr('disabled', 'disabled');
> > > > > > > > >                                    $.ajax({
> > > > > > > > >                                                   type: 'GET',
> > > > > > > > >                                                   url: 
> > > > > > > > > 'data.php',
> > > > > > > > >                                                   data: 
> > > > > > > > > 'nick=' + nick,
> > > > > > > > >                                                   success: 
> > > > > > > > > function() {
> > > > > > > > >                                                           
> > > > > > > > > $(':submit', this).removeAttr('disabled');
> > > > > > > > >                                                           
> > > > > > > > > $('#status').load('output.php');
> > > > > > > > >                                                           }
> > > > > > > > >                                                   });
> > > > > > > > >                                         });
>
> > > > > > > > > }
>
> > > > > > > > > that is sent when a very simple form (one value and button) 
> > > > > > > > > is sent.
> > > > > > > > > The thing is, it works on my local webserver, but when I 
> > > > > > > > > upload it to
> > > > > > > > > my webhost, it wont work. It works if add data.php?nick=Test, 
> > > > > > > > > then the
> > > > > > > > > data will be added into my database but not when called from 
> > > > > > > > > .ajax.- Hide quoted text -
>
> > > > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > - Show quoted text -

Reply via email to