Results 1 to 3 of 3
Thread: ajax using dollar post
-
ajax using dollar post
4 Feb 2011 @ 03.53 i am using ajax using the $.post method my code is
HTML Code:<script type="text/javascript"> $(document).ready(function() { $("#addbutton").click(function(){ $.post('task-usingdollarpost.php', { taskname: $("#taskname").val() taskname: $("#taskname").val(), taskname: $("#taskname").val() }, function(response){ $("#loading").hide(); $("#done").fadeIn(1000).text(response); } ); return false; }); }); </script> html code <form> <input type="text" name="taskname" id="taskname" size="20" /> <input type="button" name="addbutton" id="addbutton" value="Add" /> </form>
my question is using this $.post method i am able to specify the url, variables that i am passing to a php file and a function that will be called when ajax is complete however what i need is function when the ajax is being processed so that i can show a loading image and error if an error occurs
for loading i have used this code
immediately after $(document).ready(function() {Code:$("#addbutton").ajaxStart(function(){ $("#loading").css("display","block"); });
});
and for error i have used this code after the ajaxStart function
is this the right way to show the loading div which has the loading image while the ajax request is being processed when using $.postCode:$("#addbutton").ajaxError(function(){ $("#error").css("display","block"); });
also the ajaxError is not working properly for example if i were to rename the php file in the server that i have mentioned in $.post or if i have a syntax error in the php file then the ajaxError function should be executed however i am getting a browser error message and the error div is not being displayed which i have created to show when an error occurs with $("#error").css("display","block");
how to fix the ajaxError functionLast edited by CloudedVision; 6 Feb 2011 at @ 01.14.
-
4 Feb 2011 @ 07.36 I'm not sure if you can bind .ajaxStart & .ajaxError to the same element. Have a look at the jQuery documentation, they have a good example: .ajaxError() – jQuery API
-
6 Feb 2011 @ 01.14 I'd like to remind you to wrap your code in [code] tags when posting. Also, this question relates to Javascript, not PHP, so I've moved it to the appropriate forum.
Similar Threads
-
ajax using dollar post
By sudhakararaog in forum PHP, ASP & JavaReplies: 2Last Post: 6 Feb 2011, @ 01.14 -
php and ajax
By sudhakararaog in forum PHP, ASP & JavaReplies: 0Last Post: 18 Jan 2011, @ 03.45 -
jquery treeview in ajax
By Snidefeld in forum Javascript LibrariesReplies: 11Last Post: 30 Nov 2010, @ 07.41 -
loading js files in an ajax script
By stu2000 in forum Javascript LibrariesReplies: 11Last Post: 4 May 2010, @ 11.45 -
ASP Ajax Frameworks
By magicben in forum PHP, ASP & JavaReplies: 2Last Post: 4 Mar 2009, @ 12.55



LinkBack URL
About LinkBacks












Hello every one
Hi, I am new on this forum and saying hello.