/    Sign up×
Community /Pin to ProfileBookmark

Do any body experience one submit results in two ajax calls?

Hi there,

Please look at the following server log, how come one submit seems having two ajax calls:

[code]
Line 39:
trigger_error(“ajax.php, frmName={$_POST[‘frmName’]}, token={$token}”, E_USER_NOTICE);
[/code]

[code]
Line 430:
trigger_error(“Notice: ajax.php update token – {$sql} – “, E_USER_NOTICE);
[/code]

Even for the double call ajax.php, why it repeats twice of line 39 then twice of line 430? it should repeat twice of {line 39 line 430}.

Does any body have the same experience? What does the log tell or what does this log tell? Does it call ajax.php twice for one click of submit?

Thanks,

Server Log:

[code]
<errorentry>
<datetime>2012-06-11 22:55:16 (EST)</datetime>
<errornum>1024</errornum>
<errortype>User Notice</errortype>
<errormsg>ajax.php, frmName=ldDtlInfo, token=Gvikk2e5q6CBqqBUlIlup9dSdGJPEfKDOjfLqa_ONPE</errormsg>
<scriptname>C:Apachehtdocsidajax.php</scriptname>
<scriptlinenum>39</scriptlinenum>
</errorentry>

<errorentry>
<datetime>2012-06-11 22:55:16 (EST)</datetime>
<errornum>1024</errornum>
<errortype>User Notice</errortype>
<errormsg>ajax.php, frmName=ldDtlInfo, token=Gvikk2e5q6CBqqBUlIlup9dSdGJPEfKDOjfLqa_ONPE</errormsg>
<scriptname>C:Apachehtdocsidajax.php</scriptname>
<scriptlinenum>39</scriptlinenum>
</errorentry>

<errorentry>
<datetime>2012-06-11 22:55:16 (EST)</datetime>
<errornum>1024</errornum>
<errortype>User Notice</errortype>
<errormsg>Notice: ajax.php update token – UPDATE c SET T=’blKr0xXiGPd9ExPBQO8yL3c3REY8rO5mF-nJGjSvOCw’ WHERE CustID = 100 – </errormsg>
<scriptname>C:Apachehtdocsidajax.php</scriptname>
<scriptlinenum>430</scriptlinenum>
</errorentry>

<errorentry>
<datetime>2012-06-11 22:55:16 (EST)</datetime>
<errornum>1024</errornum>
<errortype>User Notice</errortype>
<errormsg>Notice: ajax.php update token – UPDATE c SET T=’blKr0xXiGPd9ExPBQO8yL3c3REY8rO5mF-nJGjSvOCw’ WHERE CustID = 100 – </errormsg>
<scriptname>C:Apachehtdocsidajax.php</scriptname>
<scriptlinenum>430</scriptlinenum>
</errorentry>
[/code]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@wowauthorJun 12.2012 — I may know the cause, but don't have a solution.

The cause could be the javascript code has to be uploaded with its html contenent. If it's loaded before with another content, it does not work . Unless it's loaded again with the new content. With ajax, we can load a different content into the same page, but javascript code has to be reloaded again with the new contenet or it does not work. That causes the same code being loaded again and again. When it's loaded twice, and when a sumit is clicked, it's triggered twice. When it's loaded three times, it's triggered three times of the same code.

Question: does javascript code has to be loaded with content? Or it will not work. How to overcome this reloaded javascript requirement?

Thanks,
Copy linkTweet thisAlerts:
@wowauthorJun 14.2012 — I may need to give you some context to understand the issue:

In the web page, there is navigation menu on left and a content panel on right. When you click on the left menu, the right content panel will change to its associated form. In the form, you use ajax to interact with server through javascript code. The javascript code is in an external file for handling all, including menu items. When content panel is changed by a click of the menu, the form submit will not work if the javascript code is not reloaded with the form. So the js code is included as part of the content panel. But the problem is when js code is reloaded twice, it triggers ajax call twice of the same action.

The question is how to avoid triggering the same ajax call more than once.

Thanks,
Copy linkTweet thisAlerts:
@toicontienJun 14.2012 — You'll need to post the HTML and JavaScript you are using before we can help you further.
×

Success!

Help @wow spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...