Thanks, Dave. I'm using over a dozen unique handlers for success and for
error. I never considered defining a single handler for each, so thank you.
(I've mentioned I'm a novice, right?) That approach would work better for
error handling, but even in many of those instances I'm doing something
unique. So it's not going to solve this tiny little problem for me.
But, since it looks like the problem is caused by my inexpert programming
skills, and that there isn't a way to exclude the error and success entries
in the function pulldown, I'll consider this question to have been
satisfactorily answered.
Thanks, Dave. And thanks, BBedit.
On Tuesday, November 20, 2012 1:20:36 PM UTC-5, Dave wrote:
>
> 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>