I am loading a content into a #result div. In that content, there is a button.
After the contrnt was loaded with ajax, i cant click on that button, i dont get the alert. (the page doesnt see it? :))
<script type="text/javascript">
$(document).ready(function(e)
{
$('#printButton').hide();
$('#submitButton').click(function(e)
{
var kat = $('#kategoria').val();
$.ajax({
type: 'POST',
url: 'files/get_arlista_kategoria.php',
data: { kat: kat },
dataType: "html",
cache: false,
beforeSend: function(){
$('#preloaderImage2').show();
},
success: function(data)
{
var result = $.trim(data);
$('#result').html(result);
$('#printButton').show();
},
complete: function(){
$('#preloaderImage2').hide();
}
});
});
// This click doesnt work
$('#savePrices').click(function(e)
{
alert("Its oké");
});
});
</script>
How can i work with this button and the input after the ajax loaded it? I want to update the product prices.
And here is the php file, this generates the html content:
<?php
include_once("../../files/connect.php");
include_once("../../files/functions.php");
if(!empty($_POST))
{
$kategoria = mysqli_real_escape_string($kapcs, $_POST['kat']);
$sql = "SELECT termek_id, termek_nev, termek_akcio, termek_normal_ar, termek_akcios_ar, mertekegyseg_nev FROM termek
LEFT JOIN webshop_mertekegyseg ON webshop_mertekegyseg.mertekegyseg_id = termek.termek_egyseg
WHERE
termek_id IN (SELECT kat_kapcs_termek_id FROM `termek_katgoria_kapcsolo` WHERE kat_kapcs_kategoria_id IN ($kategoria) ) ORDER BY termek_nev ASC";
$get = mysqli_query($kapcs, $sql) or die(mysqli_error($kapcs));
$num = mysqli_num_rows($get);
if($num > 0 )
{
echo '<form method="post">';
echo '<table class="form manufacturer-seo-form table table-hover">';
echo '<thead style="font-weight:bold;">
<tr>
<td style="text-align: left;">ID</td>
<td class="left">Megnevezés</td>
<td style="text-align: left;">Egység</td>
<td>Bruttó ár</td>
<td>Akciós ár</td>
<td style="text-align: center;">Akciós</td>
</tr>
</thead>';
echo '<tbody>';
while($i = mysqli_fetch_assoc($get))
{
?>
<tr id="sor<?php echo html($i['termek_id']); ?>">
<td style="text-align: left;"><?php echo html($i['termek_id']); ?></td>
<td class="left"><a title="Megnyitás" style="color:#333;" target="_blank" href="termek-szerkesztes.php?id=<?php echo html($i['termek_id']); ?>"><?php echo html($i['termek_nev']); ?></a></td>
<td style="text-align: left;"><?php echo $i["mertekegyseg_nev"] ?></td>
<td><input type="text" name="normal_ar" value="<?php echo html($i['termek_normal_ar']); ?>" /></td>
<td><input type="text" name="akcios_ar" value="<?php echo html($i['termek_akcios_ar']); ?>" /></td>
<td style="text-align: center;">
<select name="termek_akcio" class="input input-select" style="padding:5px 10px">
<?php
$ertek = intval($i['termek_akcio']);
$values = array("1" => "Igen", "0" => "Nem");
foreach($values AS $k => $v)
{
$selected = $ertek == $k ? ' selected="selected"':'';
echo '<option ' . $selected . ' value="' . $k . '">' . $v . '</option>';
}
?>
</select>
</td>
</tr>
<?php
}
echo '</tbody>';
echo '</table>';
echo '<div class="text-center"><button class="btn saveButton" type="button" id="savePrices">Módosítások mentése</button></div>';
echo '</form>';
}
else
{
echo '<span style="display:block;margin:20px 0 20px 5px;"><b>A kiválasztott kategóriában nincsenek termékek.</b></span>';
}
}
?>
You assign the click event function before the element (button) actually exists. Therefore there is no element to bind the click event to. You can bind the click event to the document instead:
$(document).on('click', '#savePrices', function(e) {
alert(...);
});
Completely untested though ...
The onclick assignment ($('#savePrices').click(...)) is run once when the web page has loaded. But your pricing buttons are not there yet.
Run it again when the AJAX .success is executed:
<script type="text/javascript">
$(document).ready(function(e)
{
$('#printButton').hide();
$('#submitButton').click(function(e)
{
var kat = $('#kategoria').val();
$.ajax({
type: 'POST',
url: 'files/get_arlista_kategoria.php',
data: { kat: kat },
dataType: "html",
cache: false,
beforeSend: function(){
$('#preloaderImage2').show();
},
success: function(data)
{
var result = $.trim(data);
$('#result').html(result);
// assign onclick
$('#savePrices').click(function(e)
{
alert("Its oké");
});
$('#printButton').show();
},
complete: function(){
$('#preloaderImage2').hide();
}
});
});
});
</script>
Related
I am using DataTables with ajax using PHP CodeIgniter Framework. I am having a problem with switching Active buttons to Inactive buttons, vice versa.
What I want is:
When I click Active button, It should change to Inactive in realtime without refreshing the page.
Controller:
function activateStatus() {
$id = $this->uri->segment(3);
$data = array(
'status' => 1
);
$this->equip_model->updateAccount('equip', $data, array('id' =>$id));
}
function deactivateStatus() {
$id = $this->uri->segment(3);
$data = array(
'status' => 0
);
$this->equip_model->updateAccount('equip', $data, array('id' =>$id));
}
View:
<table class="table table table-hover table-bordered" id="equipmain">
<thead>
<tr>
<th>ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach ($equip as $row){
?>
<tr>
<td style="display: none;"><?= $row->id ?></td>
<td align="center">
<?php
$status = $row->status;
if($status == "1") { ?>
<button id="<?php echo $row->id ?>" class="btn btn-xs green-jungle statusupdate1">✓</button>
<?php } else { ?>
<button id="<?php echo $row->id ?>" class="btn btn-xs red-flamingo statusupdate0" >✕</button>
<?php } ?>
</td>
</tr>
</tbody>
</table>
AJAX:
var oTable = $('#equipmain').DataTable( {
"searching": false,
"processing":true,
"columnWidth": 20,
"serverSide": true,
"autoWidth": true,
});
$(document).on('click', '.statusupdate0', function() {
var id = $(this).attr("id");
$.ajax({
url: "<?= base_url() ?>Admin/activateStatus/" + id,
success: function (data) {
oTable.ajax.reload();
}
});
});
$(document).on('click', '.statusupdate1', function() {
var id = $(this).attr("id");
$.ajax({
url: "<?= base_url() ?>Admin/deactivateStatus/" + id,
success: function (data) {
oTable.ajax.reload();
}
});
});
I don't know where is the error why the buttons are not working.
It may be that you are missing the semicolon (;) after your base_url() call. In the AJAX section for both buttons, try changing <?= base_url() ?> to <?= base_url(); ?> and see if that solves the issue.
I have some Ajax code all code working fine but the problem is the loading image showing continually.
I want to hide the image on success and also want to change background of table column.
My current code:
index.php
<?php
include_once("db_connect.php");
?>
<title>phpzag.com : Demo Inline Editing using PHP MySQL and jQuery Ajax</title>
<script type="text/javascript" src="script/jquery-3.1.1.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap-4.0.0-alpha.5-dist/css/bootstrap.min.css"/>
<script type="text/javascript" src="script/functions.js"></script>
<div class="container">
<h2>Example: Inline Editing using PHP MySQL and jQuery ajax</h2>
<?php
$sql = "SELECT id, employee_name, employee_salary, employee_age FROM table_record";
$resultset = mysqli_query($conn, $sql) or die("database error:". mysqli_error($conn));
?>
<table class="table table-condensed table-hover table-striped bootgrid-table">
<thead>
<tr>
<th>Employee Name</th>
<th>Salary</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<?php
while( $rows = mysqli_fetch_assoc($resultset) ) {
?>
<tr>
<td contenteditable="true" data-old_value="<?php echo $rows["employee_name"]; ?>" onBlur="saveInlineEdit(this,'employee_name','<?php echo $rows["id"]; ?>')" onClick="highlightEdit(this);"><?php echo $rows["employee_name"]; ?></td>
<td contenteditable="true" data-old_value="<?php echo $rows["employee_salary"]; ?>" onBlur="saveInlineEdit(this,'employee_salary','<?php echo $rows["id"]; ?>')" onClick="highlightEdit(this);"><?php echo $rows["employee_salary"]; ?></td>
<td contenteditable="true" data-old_value="<?php echo $rows["employee_age"]; ?>" onBlur="saveInlineEdit(this,'employee_age','<?php echo $rows["id"]; ?>')" onClick="highlightEdit(this);"><?php echo $rows["employee_age"]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<div style="margin:50px 0px 0px 0px;">
<a class="btn btn-default read-more" style="background:#3399ff;color:white" href="http://www.phpzag.com/inline-editing-using-php-mysql-and-jquery-ajax" title="Inline Editing using PHP MySQL and jQuery ajax">Back to Tutorial</a>
</div>
</div>
Database connection
<?php
/* Database connection start */
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dynamic_test";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
?>
Mysql update query
<?php
include_once("db_connect.php");
$sql = "UPDATE table_record set " . $_POST["column"] . " = '".$_POST["value"]."' WHERE id=".$_POST["id"];
mysqli_query($conn, $sql) or die("database error:". mysqli_error($conn));
exit;
?>
Ajax query
function highlightEdit(editableObj) {
$(editableObj).css("background", "#FFF");
}
function saveInlineEdit(editableObj, column, id) {
// No change change made then return false
if ($(editableObj).attr('data-old_value') === editableObj.innerHTML)
return false;
// Send ajax to update value
$(editableObj).css("background", "#FFF url(loader.gif) no-repeat right");
$.ajax({
url: "saveInlineEdit.php",
type: "POST",
dataType: "json",
data: 'column=' + column + '&value=' + editableObj.innerHTML + '&id=' + id,
success: function(response) {
// Set updated value as old value
$(editableObj).attr('data-old_value', editableObj.innerHTML);
$(editableObj).css("background", "#dcd8d8");
},
error: function() {
console.log("errr");
}
});
}
Use beforeSend method for ajax like success and error method.
function highlightEdit(editableObj) {
$(editableObj).css("background", "#FFF");
}
function saveInlineEdit(editableObj, column, id) {
// No change change made then return false
if ($(editableObj).attr('data-old_value') === editableObj.innerHTML)
return false;
// Send ajax to update value
//$(editableObj).css("background", "#FFF url(loader.gif) no-repeat right");
$.ajax({
url: "saveInlineEdit.php",
type: "POST",
dataType: "json",
data: 'column=' + column + '&value=' + editableObj.innerHTML + '&id=' + id,
beforeSend : function(res){
$(editableObj).css("background", "#FFF url(loader.gif) no-repeat right");
},
success: function(response) {
// Set updated value as old value
$(editableObj).attr('data-old_value', editableObj.innerHTML);
$(editableObj).css("background", "#dcd8d8");
},
error: function() {
console.log("errr");
}
});
}
As #Luka Kvavilashvili said, your $(editableObj).css("background","#dcd8d8"); will only set the background-color, and not change the other styles, so you must change it to:
success: function(response) {
// Set updated value as old value
$(editableObj).attr('data-old_value', editableObj.innerHTML);
$(editableObj).css({"background-image":"none", "background":"#dcd8d8"});
}
another good solution wold be to make use of CSS, doing
td { background: #dcd8d8; }
.loading { background: #fff url(loader.gif) no-repeat right; }
and changing the js code to something like
$(editableObj).addClass('loading');
$.ajax({
...
success: function(response) {
// Set updated value as old value
$(editableObj).attr('data-old_value', editableObj.innerHTML);
$(editableObj).removeClass('loading');
}
...
I have an array of rows, each with a radio button with the same name (name='status'). I have put the radio buttons into an index so that each radio button will reflect its correct value. However, the javascript no longer works to change the value - I am stumped with the corresponding changes I need to make to the javascript.
<form action="<?php echo $this->form_action; ?>" method="post">
<p class="hide"><input name="status" type="text" value="" /></p>
<table id="manage-items" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th><?php echo $this->translate('Item');?></th>
<th><th><?php echo $this->translate('Status');?></th></th>
</tr>
</thead>
<tbody>
<?php $ind = 0; ?>
<?php foreach ($this->items as $item) {
$item_link = 'type=product';
?>
<tr id="item_<?php echo $ind; ?>">
<td data-label="Title"><span class="orangelink"><?php echo $item->title; ?></span></td>
<td align="left" style="padding-left:22px" class="color-status-<?php echo $item['active']; ?>">
<?php if (in_array($item['active'], array(0, 1))) { ?>
<input type="radio" name="item[<?php echo $ind; ?>][status]" value="1" <?php if ($item['active'] == 1) echo 'checked'; ?>>Active
<br>
<input type="radio" name="item[<?php echo $ind; ?>][status]" value="0" <?php if ($item['active'] == 0) echo 'checked'; ?>>Inactive
<?php } else { ?>
<?php echo $item['active']; ?>
<?php } ?>
</td>
</tr>
<?php $ind++; ?>
<?php } ?>
</tbody>
</table>
</form>
<script type="text/javascript">
//console.log(jQuery)
head.ready('jquery', function () {
$(document).ready(function () {
$('input[name="radio"]').click(function () {
var status = this.value;
var id = $(this).parents('tr').attr('id');
console.log('here now')
$.ajax({
type: 'post',
url: "?module=items&controller=block&action=modDaStatusBro",
data: 'id=' + id + '&status=' + status,
beforeSend: function () {
$('#' + id).animate({
'backgroundColor': '#FFBFBF'
}, 400);
},
success: function (result) {
if (result == 'ok') {
$.get(window.location.href, function (data) {
$('#' + id).html($(data).find('#' + id).html());
setTimeout(function () {
$("#" + id + "").animate({'backgroundColor': 'transparent'}, 400).find('.tooltip').simpletooltip();
deletePage();
}, 500);
});
} else {
alert(result);
$("#" + id + "").animate({'backgroundColor': 'transparent'}, 400);
}
}
});
});
});
});
</script>
Table data elements generated in PHP between
<tr id="<?php echo $item['id']; ?>">
....
</tr>
do not appear to contain input elements named "status". The HTML generated for each value of $ind is expected to be
<input type="radio" name="item[n][status]" .... Active
<input type="radio" name="item[n][status]" .... Inactive
where n is the value of $ind. But the selector in
$('input[name="status"]').click(function () {
doesn't match the name format. A one key stroke solution would be to to add a * wild card to the selector to match "status" anywhere in the name value:
$('input[name*="status"]').click(function () {
Other possibilities exist such as adding a special class name to each radio button affected (not recommended), or add a special data attribute to each radio input to be found by query selector (feasible).
Footnote: DIV elements surrounding TR elements should not be there. DIV is not listed as a permitted child element of TBODY elements, nor a permitted parent object of TR elements.
(Answer to comment)
A jQuery plugin is needed for color animation of properties, e.g. backgroundColor.
Code can be downloaded from CDNs at
https://code.jquery.com/color/jquery.color-2.1.2.min.js , or
https://cdnjs.cloudflare.com/ajax/libs/jquery-color/2.1.2/jquery.color.min.js
or the entire package can be downloaded from GitHub
Following this link here about sending data into MySQL using AJAX, I have this output:
What I want, is to see the row with the curent rows shown in the div and not at the bottom. And how to refresh the sum, and not wait to refresh the page ?
Here is the final AJAX code:
function addFunction()
{
var selectW = $('#insert_new').val();
var selectW = $('#selectW').val();
var select_at = $('#select_at').val();
var pay = $('#pay').val();
var facture = $('#facture').val();
var select_opt = $('#select_opt').val();
if(pay!="")
{
$.ajax({
data: {'selectW': selectW, 'select_at': select_at, 'pay': pay, 'facture': facture, 'select_opt': select_opt},
type: "post",
url: "insert_buy.php",
success: function(response){
if(response=="success")
{
$('#incident_table').append('<tr><td height="30" align="center">' + selectW + '</td><td align="center">' + select_at + '</td> <td align="center" dir="ltr">' + pay + '</td> <td align="center">' + facture + '</td> <td align="center"><form action="delete.php" method="post"><input type="hidden" name="rowid" value="" /><input class="imgClass_dell" type="submit" onclick="return confirm(\'هل أنت متأكد؟\')" name="delete_sales" value="" /></form></td></tr>');
alert(data);
$('#selectW').val('');
$('#select_at').val('');
$('#pay').val('');
$('#facture').val('');
$('#select_opt').val('');
}
else
{
alert("No Data added");
}
},
error: function(){
//alert('error; ' + eval(error));
}
});
}
else
{
alert("All Fields Are Required!!");
}
}
And here is where PHP calculate the sum:
</tr>
</form>
<?php
$sum = 0;
$selectAll = "SELECT * FROM sales WHERE date_now = :date ORDER BY date_now DESC, time_now DESC";
$stmtAll=$conn->prepare($selectAll);
$stmtAll->bindValue(':date', date("y-m-d"));
$execAll=$stmtAll->execute();
$result=$stmtAll->fetchAll();
?>
<?php foreach($result as $rows){
$sum = $sum + $rows['pay'];
//var_Dump($rows) ?>
<tr>
<td height="30" align="center"><?php echo $rows['type'] ?></td>
<td align="center"><?php echo $rows['provider'] ?></td>
<td align="center" dir="ltr"><?php echo (number_format($rows['pay'], 0, ',', ' ')). ' L.L'?></td>
<td align="center"><?php echo $rows['facture'] ?></td>
<td align="center"><form action='delete.php' method="post">
<input type="hidden" name="rowid" value="<?php echo $rows['id'] ?>" />
<input class="imgClass_dell" type="submit" onclick="return confirm('هل أنت متأكد؟')" name="delete_sales" value="" />
</form></td>
</tr>
<?php } ?>
<tr>
<th colspan="4" align="center" bgcolor="#666666">المجموع</th>
<td dir="ltr" bgcolor="#666666" align="center"><?php
echo ($sum = number_format($sum, 0, ',', ' ')). ' L.L';
?></td>
</tr>
</table>
</div>
</div>
I hope I can get some help.
you can try with this
You'll need a getTable.php page that displays your table, and nothing else: no headers, footers, etc.
PHP (getTable.php) - this can be any server side code (asp, html, etc..)
<?php
echo '<table><tr><td>TEST</td></tr></table>';
?>
Then, in your JS, you can easily refresh the table by using the load() method:
HTML
<div id="tableHolder"></div>
js
<script type="text/javascript">
$(document).ready(function(){
refreshTable();
});
function refreshTable(){
$('#tableHolder').load('getTable.php', function(){
setTimeout(refreshTable, 5000);
});
}
</script>
try and good luck i prefer work with jqgrid
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm working on a Shopping cart. I'm adding product to cart First. Then using Ajax to Change the item Quantity On Change. This process works perfectly on First Change. But when I'm changing the quantity again the portion not refreshed.
Here is coding to display Cart Details
<?php
$session_id = $_SESSION["session_id"];
$query = "select c.cart_id, c.item_quantity, p.category_name, p.product_thumb, p.reduced_price from cart as c inner join category as p on c.category_id = p.category_id where c.session_id = '$session_id'";
$select_cart = mysqli_query($mysqli, $query);
if (mysqli_num_rows($select_cart) > 0)
{
?>
<table>
<tr>
<th>Item</th><th>Item Detail</th><th>Quantity</th><th>Price</th><th>Sub Total</th>
</tr>
<?php
while ($result_cart = mysqli_fetch_object($select_cart))
{
?>
<tr id="cart<?php echo $result_cart->cart_id; ?>">
<td width="100" align="center"><img src="images/products/<?php echo $result_cart->product_thumb; ?>" width="50" /></td>
<td><?php echo $result_cart->category_name; ?><br /><?php echo $result_cart->product_name; ?></td>
<td width="50" align="center">
<select class="quantity" id="quantity<?php echo $result_cart->cart_id; ?>" >
<?php
for ($i = 1; $i <= 10; $i++)
{
?>
<option value="<?php echo $i; ?>" <?php if ($result_cart->item_quantity == $i) { echo "selected"; } ?>><?php echo $i; ?></option>
<?php
}
?>
</select>
</td>
<td width="75" align="center">$<?php echo $result_cart->reduced_price; ?></td>
<td width="100" align="center">$<?php echo $result_cart->item_quantity * $result_cart->reduced_price; ?>
<a title="Delete" href="delete-cart.php?id=<?php echo $result_cart->cart_id; ?>" class="delete"></a></td>
</tr>
<?php
}
?>
</table>
<?php
}
else
{
?>
<p>Cart is Empty..!</p>
<?php
}
?>
And this is the Ajax script using on Same page
<script type="text/javascript">
$('.quantity').change( function()
{
var ID = $(this).attr("id");
var sid=ID.split("quantity");
var New_ID=sid[1];
var QTY = document.getElementById(ID).value;
var URL='updatecart.php';
var dataString = 'id=' + New_ID +'&qty='+ QTY;
$.ajax({
type: "GET",
url: URL,
data: dataString,
cache: false,
success: function(data){
$('#cart'+New_ID).html(data);
alert (data);
}
});
});
</script>
And Here is the code where I'm updating Data into database- updatecart.php.
<?php
include('admin/includes/config.php');
if(isset($_GET['id'])) {
$cart_id = ($_GET['id']);
$item_quantity = ($_GET['qty']);
mysqli_query($mysqli, "update cart set item_quantity = '$item_quantity' where cart_id = '$cart_id'");
// Loop through the products and output HTML for JavaScript to use
?>
<?php
$query = "select c.cart_id, c.item_quantity, p.category_name, p.product_thumb, p.reduced_price from cart as c inner join category as p on c.category_id = p.category_id where c.cart_id = '$cart_id'";
$select_cart = mysqli_query($mysqli, $query);
$result_cart = mysqli_fetch_object($select_cart);
?>
<td width="100" align="center"><img src="images/products/<?php echo $result_cart->product_thumb; ?>" width="50" /></td>
<td><?php echo $result_cart->category_name; ?><br /><?php echo $result_cart->product_name; ?></td>
<td width="50" align="center">
<select class="quantity" id="quantity<?php echo $result_cart->cart_id; ?>" >
<?php
for ($i = 1; $i <= 10; $i++)
{
?>
<option value="<?php echo $i; ?>" <?php if ($result_cart->item_quantity == $i) { echo "selected"; } ?>><?php echo $i; ?></option>
<?php
}
?>
</select>
</td>
<td width="75" align="center">$<?php echo $result_cart->reduced_price; ?></td>
<td width="100" align="center">$<?php echo $result_cart->item_quantity * $result_cart->reduced_price; ?>
<a title="Delete" href="delete-cart.php?id=<?php echo $result_cart->cart_id; ?>" class="delete"></a></td>
<?php
}
?>
I need to automatically calculate the Subtotal Price and Total prices of cart on Changing the Quantity of particular items. I'm new to Ajax.
These are the similar Questions.
1. Ajax form only work one time
2. Ajax Request works only once - code Ignitor
After refering these questions I tried to use something like this $('.quantity').on( "change", "select", function() {But Not getting Result.
Please help me. Do I need to Change the whole coding Structure.
You are changing the DOM after ajax success (using the html() method). The element is replaced with a new one, thus your events are removed.
Also, your other fix is only applying the change on quantity elements that also have been removed. Try something like
$(document).on( "change", ".quantity", function() {}
i have found 2 issues:
1. always use jQuery's document-ready function around DOM related events:
$( document ).ready(function() {
//DOM EVENTS
});
2. your event doesn't work on live-generated DOM elements:
$( '.quantity' ).change( function(){} );
change it to:
$( document ).on('change', '.quantity', function(){} );
this will also add event listeners to DOM elements with the class "quantity" that have been generated after the document loaded for the first time.
This is not the best solution but, at least, it may work as a workaround. Your can do the following in your code:
<script type="text/javascript">
$('.quantity').change(selectChange);
function selectChange()
{
var ID = $(this).attr("id");
var sid=ID.split("quantity");
var New_ID=sid[1];
var QTY = document.getElementById(ID).value;
var URL='updatecart.php';
var dataString = 'id=' + New_ID +'&qty='+ QTY;
$.ajax({
type: "GET",
url: URL,
data: dataString,
cache: false,
success: function(data){
$('#cart'+New_ID).html(data);
$('.quantity').change(selectChange);
alert (data);
}
});
}
</script>
I assume that your "select" is removed and re-appended on the ajax call success callback, so, the events won't be binded more than once.