FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP/AJAX Problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: PHP/AJAX Problem [message #170841 is a reply to message #170829] Wed, 01 December 2010 15:08 Go to previous messageGo to previous message
Helmut Chang is currently offline  Helmut Chang
Messages: 22
Registered: September 2010
Karma:
Junior Member
Am 01.12.2010 01:26, schrieb bruceaj:

> Here is my Code. This is the call from my main routine
>
> <input name="btnSearch" type="submit" id="btnSearch"
> onclick="getData('results')", value="Submit Search" />
^
Is this a typo?

As others already wrote: Here you have a submit button. So it does two
things, when clicked:

Calls the JavaScript function
*and*
submits the form (if it's within a form).

That triggers two requests, where I guess, the response of the
form-submit "overwrites" the response from the AJAX call.

Solution: either use a <input type="button" />, which wouldn't submit
the form. Or use your submit-button and return false from the click
handler to suppress the submitting of the form. But this makes only
sense, if you want a fallback in submitting the form, if JavaScript is
turned off or your JavaScript functions return a correct true or false,
depending whether the call succeeded or not.

> <div id-'results'></div>
^
Is this a typo? With this, I don't think, you would have an element with
the id "results".

Helmut
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: return value?
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Oct 21 05:29:39 GMT 2024

Total time taken to generate the page: 0.04042 seconds