How to present a modal when Axios catch gives a 404 error - axios

If there is a coms failure axios will throw a 404 error. The below code nicely puts up an error message on my page:
["catch"](function (error) {
$("div.comsAlert").addClass("alert alert-danger").text('There is a communications failure. Please Refresh the page, and try again');
});
Great, however, what I really want is a Bootstrap modal to be presented on my page. There is quite a bit of HTML. I have tried Jquery append with no luck.
Any ideas?
Bootstrap 5 modals

Related

Flutter web: How to hide alert message in the console when the HTTP status codes is failed?

I am using the API in Flutter.
Sometimes the server will return failed HTTP status codes and Flutter always auto-generated the alert message with shown the API URL in the console. I don't want to shown the API URL and this alert message makes the app look not complete from the user's perspective. I want to hide these alert messages. How to do that?
Example:
You can use the try/catch block.
try {
await http.get('...')
...
} catch(e) {
print(e);
}
'This is normal behavior for the browser' By https://github.com/flutter/flutter/issues/112155#issuecomment-1255310351
This is a way that can clear the console -> https://stackoverflow.com/a/73862039/17798537

jquery.form.js is not working in Internet Explorer 9

I have a simple form with a file upload control. The form will be posted once I click on the upload button. I'm trying to do a jquery-ajax post, using the jquery.form.js.
My code is as follows,
var options = {
beforeSubmit: function (formData, jqForm, options) {
$(".loaderImage").show();
return true;
},
success: function (responseText, statusText, xhr, $form) {
$("#result").html(responseText);
},
error: function(xhr) { alert(xhr.responseText); }
};
$("#AjaxFileUpload").ajaxSubmit(options);
return false;
It works fine in Google Chrome, Firefox and Internet Explorer 10. The problem with Internet Explorer 9 is, after debugging, it doesn't enter the success(). Any pointers on what's going wrong? There are no errors in the console either.
I added the error option as well, but the issue is the same, the breakpoint doesn't hit the alert.
I just had a look at the network traffic. There is no POST request going (in Internet Explorer 9) when I click the upload button, but there's a POST request going in Internet Explorer 10.
I cleared the cache and reset browser settings as well. But the issue persists.
badZoke, I was experiencing this same problem yesterday and most of today and finally figured out what was causing it (in my case). This might be helpful for your situation, as well:
Internet Explorer has restrictions about form submission when the form is not currently in the DOM. In my case, a user interacted with a button in a modal popup (which also contained the form). When they clicked, the form was removed from the DOM (but still accessible via a js var) and replaced with a loading bar. I then called myForm.ajaxSubmit(options); which in IE<10 attempts a submission of that form to a temporary <iframe/>. Not allowed unless the form is in the DOM.
If your code above was a simplification of your actual scenario and you were doing something similar to me, this may be your problem. Best of luck.
The first step would be to see if the error callback is invoked:
var options = {
beforeSubmit: function (formData, jqForm, options) {
$(".loaderImage").show();
return true;
},
success: function (responseText, statusText, xhr, $form) {
$("#result").html(responseText);
},
error: function(xhr) { alert(xhr.responseText); }
};
$("#AjaxFileUpload").ajaxSubmit(options);
Your code is working fine on my computer, and I'm using Internet Explorer 9. Maybe the problem is not here.

The graph api /me/apprequests return http error

I use
FB.api('/me/apprequests/?access_token=' + access_token + '&date_format=' + escape('Y/m/d H:i:s eO'), function(response) {
if(response.error)
{
to get user's app requests.
but some times,some users cannot get the app requests list.
only get
{"error":{"type":"http","message":"unknown error"}}
some users may get this error all the time.
I trace this error to my GA quality,Statistical results show some users get this error As many as tens of thousands of times.
the access_token is the current user's.
why some user get unknown error with type http?
I do not get this.
thank you.
thanks for your answer.
I think this error is not caused due to the permission.because I log the access_token when one error occurs.and use facebook debug tool check it.It shows
Issued:
1362702044 (about an hour ago)
Expires:
1367886044 (in about 2 months)
Valid: True
Origin: Web
Scopes: email publish_actions user_games_activity
.So ,I do not known why those problem occur.
I have the same problem and it is resolved now.
The error message : {"error":{"type":"http","message":"unknown error"}}
means FB API's response is broken because of some other action in the page.
In my scenario, I put a html tag :button in a form, and this button is to invoke FB.api. However, when a user clicks the button, the form will be submitted automatically and does not wait the response of FB.api.
The code is as below:
<form>
<button onclick="test();">Test</button>
</form>
function test(){
FB.api('/me', function(response) {
alert(response.name);
});
}
I add "return false;" in button's onclick method after it calls test() to avoid the form automatically submitting.
I suggest you to check the javascript in the page to confirm there is no action occurs during interactive function with FB.

Facebook Register Plugin - Form submitting even though validation fails?

I'm using the Facebook Registration Plugin (http://developers.facebook.com/docs/plugins/registration/) to register users for our site. The problem is I can't seem to get custom validation working and was wondering whether it's a mistake on my part or something wrong with Facebook.
This is the XFBML code that I'm using:
<fb:registration
fields="[{'name':'name'},
{'name':'email'},
{'name':'password','description':'Enter a password','type':'text'}]"
redirect-uri="http://local.dev"
onvalidate="validateFacebookRegistrationForm">
</fb:registration>
and I have a global function called validateFacebookRegistrationForm which has the following code in it:
function validateFacebookRegistrationForm(form) {
errors = {};
if (form.password == "") {
errors.password = "No Password Entered";
}
return errors;
}
I would expect hitting the register button on the form would do nothing and the validation message would show up... instead I get a popup like this:
http://i.imgur.com/ERxw3.jpg
Once the popup is closed, the form is validated ... and the error message shows. Clicking register again will not submit the form until the errors have been fixed - which is the how the form should behave in the first instance!
The Facebook Registration plugin does not client-side validate until AFTER the user has pressed "Register" and then in the popup pressed "Continue". Then, it will do the "client-side" validation... it really doesn't make sense to go in that order but that's how it seems to be.
Your code is fine.

Can't get FB Registration Client side validation to work

I'm following the instructions given on FB Developer, but I just can't get client side verification to work on my registration form.
This code block is present in the body of my page:
<script src="http://connect.facebook.net/en_US/all.js#appId=000000000&xfbml=1"></script>
<fb:registration
fields="[{'name':'name'},{'name':'emailEdu','description':'Your .edu Email','type':'text'}]"
redirect-uri="http://www.lazydragonbooks.com"
onvalidate="validate">
</fb:registration>
<script>
function validate(form)
{
errors = {};
if (form.emailEdu !== "foo")
{
errors.foo = "You didn't type foo";
}
return errors;
}
</script>
EDIT:
I placed alert('foo') as the first line in the validate function but don't get the alert so it seems the function does not get called.
Check the Chrome debugging tools console errors for a javascript error. I am guessing something is failing that is causing it not to validate properly. Also, the line should be errors.emailEdu = "You didn't type foo"; not errors.foo = ...
I had the same problem while running the code on my local dev server. As soon as I ran the code at the domain URL registered for my Facebook app, it all worked fine.
That also fixed a problem where a weird 3 bar progress indicator was persisting on top of the registration form.