我有这个联系表3 - 4年,它工作正常,直到jquery 1.9
HTML
<form id="Newsletter">
<table>
<tr>
<td><input id="jezik" name="jezik" type="hidden" value="hr" />
<input id="NewsletterIme" name="NewsletterIme" type="text" onFocus="if(this.value == 'Ime i prezime*') { this.value = ''; }" onBlur="if (this.value == '') {this.value = 'Ime i prezime*';}" value="Ime i prezime*" /><br>
<input id="NewsletterEmail" name="NewsletterEmail" type="text" onFocus="if(this.value == 'E-mail*') { this.value = ''; }" onBlur="if (this.value == '') {this.value = 'E-mail*';}" value="E-mail*" /></td>
<td style=" vertical-align:bottom;"><input name="submit" type="submit" class="button" value="" /></td>
</tr>
</table>
</form>
<div id="note1" style="clear:both;"></div>
的javascript
$(document).ready(function(){
$("#Newsletter").submit(function(){
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "/newsletter-obrada.php",
data: str,
success: function(msg){
$("#note1").ajaxComplete(function(event, request, settings){
var jezik = $('#jezik').val();
if(msg != 'OK')
{
result = msg;
}
else
{
window.location.replace("/" + jezik + "/thank-you");
}
$(this).html(result);
});
}
});
return false;
});
});
PHP
<?php
/*
Credits: Bit Repository
URL: http://www.bitrepository.com/
*/
require_once('admin/config.php');
define("WEBMASTER_EMAIL", 'luka@fer-projekt.com');
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post)
{
$jezik = $_POST['jezik'];
$NewsletterEmail = trim($_POST['NewsletterEmail']);
$NewsletterIme = $_POST['NewsletterIme'];
$NewsletterGodiste = $_POST['NewsletterGodiste'];
$NewsletterVrsta = $_POST['NewsletterVrsta'];
$sigureca = $_POST['sigureca'];
$poruka = stripslashes($_POST['poruka']);
$error = '';
//jezici
if($jezik == "hr") {
$tekst_kontakt_greska1 = "Niste upisali ime. <br>";
$tekst_kontakt_greska2 = "Niste odabrali grupu. <br>";
$tekst_kontakt_greska3 = "Niste upisali e-mail. <br>";
$tekst_kontakt_greska4 = "Neispravan e-mail. <br>";
$tekst_kontakt_greska5 = "Neispravan sigurnosni kod. <br><br>";
}
if($jezik == "en") {
$tekst_kontakt_greska1 = "You didn’t write your name. <br>";
$tekst_kontakt_greska2 = "You didn’t write your group. <br>";
$tekst_kontakt_greska3 = "You didn’t write your e-mail. <br>";
$tekst_kontakt_greska4 = "Invalid e-mail. <br>";
$tekst_kontakt_greska5 = "Invalid security code. <br><br>";
}
//provjera imena
if(strpos($NewsletterIme, '*'))
{
$error .= $tekst_kontakt_greska1;
}
//checks for an email
if (empty($NewsletterEmail)) {
$error .= $tekst_kontakt_greska3;
} else {
if (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", stripslashes($NewsletterEmail))) {
$error .= $tekst_kontakt_greska4;
} // if eregi
} // if empty email
//provjera imena
if(!$error)
{
$mail = mysql_query("INSERT INTO newsletter (NewsletterEmail, NewsletterIme) VALUES ('$NewsletterEmail', '$NewsletterIme')");
if($mail)
{
echo 'OK';
}
}
else
{
echo '<div class="notification_error">'.$error.'</div>';
}
}
?>
所以现在注意到当我点击提交bottun时。如果我改为jquery 1.8,它可以正常工作。有人有任何想法吗?
答案 0 :(得分:1)
应根据jquery 1.9更改日志将AJAX事件附加到文档。
$("#note1").ajaxComplete(function(event, request, settings)
将其更改为:
$(document).ajaxComplete(function(event, request, settings)
文档
答案 1 :(得分:0)
从jQuery 1.9开始,全局Ajax事件仅在文档节点上触发:http://jquery.com/upgrade-guide/1.9/#ajax-events-should-be-attached-to-document