Unable to refresh the cache of IE browser - javascript

I am trying to log in into my webpage in IE browser, the problem is that it allows user to login but the headers and the interface made for login account does not shows up instead previously cached data is shown...and when i refresh the page then only user is able to see the new data for log in member...i am using spring and angular java script.
webpage works fine in other browsers.
thanks in advance

If your using ajax to load the data then you need "cache: false" in IE.
$.ajax({
url: url,
type: 'POST',
cache: false,
data:data,
success: function (result) {
}
});

Related

How to create secure page for a mobile app using phonegap

I'm working a simple mobile app and I'm using HTML, CSS, Javascript, ajax, PHP and Mysql and Phonegap. The mobile app has a login and I'm using ajax to send the data to a php file located on a separate server if the login is successful the app loads a diferent page, only users that are register can see this page.
The problem that I'm facing is that when I'm on the next page I don't know how to verify that the user has the access. I was thinking on using a window variable or localstore but I don't know if this is a good idea or not.
Can some one point me in the right direction on this topic.
Just sit and think. Use localStorage.setItem if user is registered/logged on ajax call. Later control that on easy way. Check this example.
Ajax call:
$.ajax({
type: "POST",
url: "http://exampleUrl.com/php1/insert.php",
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function() {
$("#insert").val('Connecting...');
},
success: function(data) {
if (data == "success") {
alert("You can login now!");
$("#insert").val('Wait...');
localStorage.setItem("logged", logged); // Save if user is successfuly registered and control on other page
//console.log(dataString);
loadiranje_paIndex();
} else if (data == "error") {
alert("Error! Try another username!");
$("#insert").val('Register');
/*location.href = '/register.html'; */
}
}
});

Android webview make ajax request both get and post

I am developing an application that is using webview.
Inside the webview, I am doing a POST request using ajax.
In iOS, it can work as I want.
However, in android, the request turns out to be doing two request: GET and POST.
It makes a routing error on the server side because it should be for POST only.
This is the ajax request code. I don't think there is something wrong with the code since it works well when I open the html page on computer browser and iOS webview.
window.onload = function () {
$.ajax({
type: "POST",
url: "<%= notif_read_notif_path %>",
data: {"personal_notice" : {"notice_info_id" : 123}},
dataType: "json",
success: function(response) {
alert(response);
}
});
};
Is there anyone experiencing the similar problem?

Wikipedia API. File not found Error

I'm trying to make a wikipedia search bar. The idea is to send a new AJAX request every time search input is changed. I'm using https://www.mediawiki.org/wiki/API:Search_and_discovery as a guideline.
var search = $('#search');
search.keyup(function() {
if (search.val() === '') {
result.html('');
}
$.ajax({
url: '//en.wikipedia.org/w/api.php',
data: {
action: 'query',
list: 'search',
format: 'json',
srsearch: search.val()
},
dataType: 'jsonp',
success: function(response) {
console.log("success!");
}
});
});
However, success function is not even triggered.
On any keypress the error I get is this ("d" pressed):
jquery-2.1.1.min.js:4 GET file://en.wikipedia.org/w/api.php?>callback=jQuery21107844703783826772_1484403407494&action=query&list=search&srse>arch=d&format=json&_=1484403407495 net::ERR_FILE_NOT_FOUND
Thank you in advance for any help or guidance!
Well, you're probably trying to do a AJAX request without a local server (opening your file directly in the browser).
First of all, your url options starts with //en... (without the protocol). It indicates that it'll construct your full url using the same protocol you're using. In this case: file://. That's because your browser is trying to reach file://en.wikipedia.org/....
So, you can set your url to https://en.wikipedia.org/w/api.php to make it work.
Just replace:
url: '//en.wikipedia.org/w/api.php',
with:
url: 'https://en.wikipedia.org/w/api.php',
Looks like you're running it from a simple html file located in your filesystem, in other words not running it from a web server (even local).
Try calling the api with
url: 'https://en.wikipedia.org/w/api.php'
or run the file from a web server (can be a local one).

Login Form API Response Code

I'm creating an API endpoint for a mobile app and for computer web browsers. Both devices use the same API endpoint with a POST request sent to /users/session for authentication. The mobile phone requires a 200 Status Code response. However, as login forms do, I need to redirect browsers to the home logged in page where the user can see their information. Do I return a 301 subsequently after? What is the best practice to implement this?
In summary: I need to use the same API endpoint for mobile and computer, but am unsure how to redirect while returning a 200 Status Code.
It seems like a 200 OK is the proper code to return upon successful login. This makes the API more generic and doesn't tie it to any particular use (mobile vs desktop). You might try placing the redirect logic in the desktop site itself and use ajax to submit the data. This will give you more flexibility for handling login errors as well. This is a basic example with jquery.
$.ajax({
type: "POST",
url: "/users/session",
data: loginForm,
success: function(){
//Redirect user to home page
window.location.replace("/home");
},
dataType: dataType
});
try this
$.ajax(serverUrl, {
type: "POST",
data: dataToSave,
statusCode: {
200: function (response) {
alert('200');
},
201: function (response) {
alert('201');
}
}, success: function () {
alert('1');
},
});

Jquery ajax 'patch' doesn't seem to be sending data

I have the following javascript code...
function editShipment(){
var method = "PATCH";
var serializedData = $form.serialize();
$.ajax({
type: "PATCH",
url: Routing.generate('api_1_shipment_patch_shipment', {api_key: API_KEY, id:$('#caddress-shipmentID').val()}, true),
data: serializedData,
success: newShipmentSuccess,
error: newShipmentError
});
}
When I run this code the Chrome developer tools "network" tab shows a patch method with data being sent to the correct URL.
however my application never receives this data.
Is it possible that the network tab is somehow wrong and that my browser isn't actually sending the data.
I'm using the latest jQuery and the receiving application is a Symfony2 web app.
Thanks in advance,
M
EDIT: It also worth noting that i have a test case passing for this patch method within my symfony codebase. so thats why I'm looking at Javascript as the culprit.

Categories

Resources