php - Jquery Ajax Insert Extremely Slow -
i having tough time trying figure out why onblur, triggers ajax call taking long time finish. takes dozens of seconds @ times. seems more of "description" fields have, longer takes. can review code, , tell me if think i'm missing something?
var description; var id; $(".description").live('blur',function() { var success; var datatype; $(".dynamic_row,<?php echo $services; ?>").each(function() { var row = $(this); var id = row.find(".id").val() || 0; var description = row.find(".description").val() || ""; var q = <?php echo $q; ?>; $.ajax({ type: "post", url: 'setdescname.php', data: {ider:id, descriptionr:description, qr:q}, success: function(result) { if(result.isok == false) alert(result.message); }, datatype: datatype }); }); });
<?php echo $services; ?>
pulls in 16 names of possible dynamic rows activated checkbox. part works fine...
this code in setdescname.php
require_once('include/database.php'); if (!dbconnect()) { echo 'error connecting database'; exit; } $id = $_post['ider']; $description = $_post['descriptionr']; $q = $_post['qr']; $qry = "update items set description = '".$description."' id = '".$id."'"; $result = mysql_query($qry) or die(mysql_error());
if think matters, have following earlier in code.
$.ajaxsetup({async:false}); $.ajaxsetup({cache:false});
this required, because users in ie, , cache ajax calls, rendering addition of new "dynamic" fields without necessary functionality (bringing mysql_insert_id()
on new adds).
all of work, it's painfully slow...
i appreciate advice or suggestions. thanks.
for fast need ajax cache , ajax async
ajax cache
$.ajax({ url: '/?=testdefault', data: { 'cache': 'default' } });//no timestamp
$.ajaxsetup({ cache: false }); $.ajax({ url: '/?=testfalse/', data: { 'cache': 'false' } });//yes, timestamp $.ajaxsetup({ cache: true }); $.ajax({ url: '/?=testtrue/', data: { 'cache': 'true' } }); //no timestamp
for ajax async
$.ajax({ url: "super.php", data: "a="+a, type: "post", async: false, success: function(data) { alert(data); } });
Comments
Post a Comment