How many unique success and error handlers are you using? If you're doing
the same things, you don't need to keep recreating the same functions every
time you make an ajax request. Just declare them and re-use them.
function successHandler(data, textStatus, xhr) {
if (status !== 200) {
this.error(xhr, textStatus, "bad HTTP response");
} else if (! data || $.isEmptyObject(data)) {
this.error(xhr, textStatus, "no data returned");
} else {
doSomethingWithThe(data);
}
}
function errorHandler(xhr, textStatus, errorText) {
if (console && console.error) {
console.error(errorText, textStatus, xhr.getAllResponseHeaders());
}
showError(getMessageString(textStatus, errorText));
}
$.ajax({
type: "POST",
url: "somescript.php",
success: successHandler,
error: errorHandler
})
This way you only have to define each unique function once, and each will
show up only once in the function menu and will have a name associated with
it.
On Saturday, November 17, 2012 10:55:55 AM UTC-5, dweinberger wrote:
>
> I have a javacript program that uses lots of (more likely: too many) AJAX
> calls. I use the jquery syntax:
>
> $.ajax({
> type: "POST",
> url: "somescript.php",
> success: function(){
> alert("Yay!");
> },
> error: function(){
> alert('Boo!');
> }
> })
>
> The dropdown list of functions at the top of the BBedit edit window lists
> every "success" and every "error." Is there a way to exclude them? (This is
> a minor annoyance at worst.)
>
> Since I am a sloppy, incompetent, hobbyist programmer, I am open to being
> told that the problem is with how I'm writing code.
>
> Thanks!
>
>
>
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>