WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Javascript problem. Submit button on form does nothing. (4 posts)

  1. 420DankStank
    Member
    Posted 1 year ago #

    I have a form on my site. You enter three fields and click submit, and it is supposed to return with some text. The submit button is no longer working. The custom plugin php file has this bit of code that I believe is supposed to be the calling function for that submit button.

    $content .= '
    <script type="text/javascript">
    var $j = jQuery.noConflict();
    $j(window).load(function(){
    $j("#pubverify-form").submit(function() {
    var str = $j(this).serialize();
    $j.ajax({
    type: "POST",
    url: "' . $cs_base_dir . 'verify.php",
    data: str,
    success: function(msg){
    $j("#note").ajaxComplete(function(event, request, settings)
    {
    $j(this).html(msg);
    });
    }
    });
    return false;
    });
    });
    </script>';

    Does it need to be updated some how to coincide with JQuery 1.9? This was built during v.1.6. I've tried editing it a few times, but only made it worse.

    Please help!

  2. 420DankStank
    Member
    Posted 1 year ago #

    There is also this:

    // now we put all of the HTML for the form into a PHP string
    		$content .= '<div id="verify-a-rec" class="clear">';
    			$content .= '<div id="fields">';
    			$content .= '<h4>Verify A Recommendation</h4>';
    			$content .= '<div class="verify_search">';
    				$content .= '<form id="pubverify-form" action="">';
    						$content .= '<div 
    
    class="label_wrap_verify"><label class="error" for="search_last_name">Last Name </label>';
    						$content .= '<div 
    
    class="input_wrap_verify"><input name="search_last_name" type="text" 
    
    id="search_last_name"/></div></div>';
    						$content .= '<div 
    
    class="label_wrap_verify"><label class="error" for="search_dob">Birthdate (mm-dd-yyyy) </label>';
    						$content .= '<div 
    
    class="input_wrap_verify"><input name="search_dob" type="text" id="search_dob"/></div></div>';
    						$content .= '<div 
    
    class="label_wrap_verify"><label class="error" for="search_issue_date">Issue Date (mm-dd-yyyy)</label>';
    						$content .= '<div 
    
    class="input_wrap_verify"><input name="search_issue_date" type="text" 
    
    id="search_issue_date"/></div></div>';
    					$content .= '<div class="button_wrap"><input 
    
    type="submit" value="Verify" class="button" id="pubverify-submit" /></div>';
    				$content .= '</form>';
    			$content .= '</div>';
    			$content .= '</div>';
    			$content .= '<div style="clear:both"></div>';
    			$content .= '<div id="note">';
    			$content .= '<p>Enter a Recommendation ID and click Verify!</p>';
    				$content .= '<div class="patient_wrapper">';
    					$content .= '<div class="results_label">First Name 
    
    </div>';
    					$content .= '<div class="results_label">Last Name 
    
    </div>';
    					$content .= '<div class="results_label">Date of Birth 
    
    </div>';
    					$content .= '<div class="results_label">Issue Date 
    
    </div>';
    					$content .= '<div class="results_label">Expiration Date 
    
    </div>';
    					$content .= '<div class="results_label">Dr. Information 
    
    </div>';
    				$content .= '</div>';
    			$content .= '</div>';
    		$content .= '</div>';
    	return $content;
    }
  3. 420DankStank
    Member
    Posted 1 year ago #

    So if I enter info into the form and click submit, nothing is happening on the webpage. However, I can check the developer tools -> network tools, it shows the verify php file. I click it and it shows the header requests and responses. The header response shows the correct info, but for some reason it is not displayed. HELP?

  4. 420DankStank
    Member
    Posted 1 year ago #

    Well, no thanks here, but I did get an answer on Stack Overflow. I had to change the first bit of code to remove the ajaxComplete part.

    $j.ajax({
       type: "POST",
       url: "' . $cs_base_dir . 'verify.php",
       data: str,
       success: function(msg){
           $j("#note").html(msg);
        }
     });

    It works now.

Topic Closed

This topic has been closed to new replies.

About this Topic