www.webdeveloper.com
Results 1 to 4 of 4

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

  1. #1
    Join Date
    Feb 2011
    Posts
    83

    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:
    Line 430: 
    	trigger_error("Notice: ajax.php update token  - {$sql} - ", E_USER_NOTICE);
    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:\Apache\htdocs\id\ajax.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:\Apache\htdocs\id\ajax.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:\Apache\htdocs\id\ajax.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:\Apache\htdocs\id\ajax.php</scriptname>
    	<scriptlinenum>430</scriptlinenum>
    </errorentry>
    Last edited by wow; 06-11-2012 at 11:14 PM.

  2. #2
    Join Date
    Feb 2011
    Posts
    83
    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,

  3. #3
    Join Date
    Feb 2011
    Posts
    83
    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,

  4. #4
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles