How can i apply google one tap login on my Shopify theme
i have try this code
window.onload = function () {
google.accounts.id.initialize({
client_id: 'client_id',
callback: handleCredentialResponse
});
google.accounts.id.prompt();
}
function handleCredentialResponse(res) {
$.ajax({
url: url,
type: "post",
data: res,
success: function (data) {
console.log(data);
}
});
}
but when i run simple script is working properly but when i using theme app extension is not working and below error given
https://i.imgur.com/RtADEdP.png
how can i solve this error ?
I'm new to DOJO and following the documentation on Dojo official website i wrote my code for POST request as below. But its not working and its giving me error "Unable to load myURL status: 0".
Please help.
require(["dojo/request","dojo/dom","dojo/on"],function(request,dom,on){
try{
//Access TextFields Value
var txt_UserName=dom.byId("usrName");
var txt_Password=dom.byId("password");
//Attaching click event on Button
on(dom.byId("loginButton"),"click",function(evt){
//alert(txt_UserName.value);
request.post(myURL,{
handleAs: "json",
data:{
userId: txt_UserName.value,
password: txt_Password.value,
},
headers:{
"Content-Type": "application/x-www-form-urlencoded",
}
}).then(function(response){
alert(response);
},
function(error){
alert(error);
}
);
});
}
catch(error){
alert(error.message);
}});
I need a cross-domain user login request instance, please help me, thank you!!
My code
Ext.data.JsonP.request({
url: 'http://25.30.2.3:8080/newvbo/applyaction!longin',
params: {
username:'13881901678',
password:'111111',
},
success: function(response, opts) {
alert('1');
},
failure: function(response, opts) {
alert('2');
}
});
My question is, I not receive the server returns the value, I wrong?
You can Try this
Ext.Ajax.request({
method:'GET',
contentType:'application/json; charset=utf-8',
dataType:'json',
url:'http://........Login',
disableCaching: false,
withCredentials: true,
useDefaultXhrHeader: false,
callbackKey: 'callback',
params: {
EmailId:Ext.getCmp('usernametwoway').getValue(),
Password:Ext.getCmp('loginpasswordtwoway').getValue(),
},
success:function(response)
{
console.log(response);
var res = response.responseText;
var jsonarr = Ext.decode(response.responseText);
console.log(jsonarr);
var myres = jsonarr[0].Result;
console.log(myres);
switch(myres)
{
case '1':
console.log("Registration response is successfully");
Ext.Viewport.setActiveItem({xtype:'passengerdetailstwoway'});
break;
case '0':
console.log("Failed");
Ext.Msg.alert("Error","Login Failed",Ext.emptyFn);
break;
Based on the responce you can Specify the Switch case..
Hi #jesse you can try for cross-domain something like this,
Ext.Ajax.request({
url: 'your_url_path',
timeout: 90000,
params: {
withCredentials: true,
useDefaultXhrHeader: false,
username:'13881901678',
password:'111111',
},
success: function(response, o) {
if(response != '') {
alert('1')
}
},
failure: function(response, o) {
alert('2')
}
})
For cross-domain you need put withCredentials: true and useDefaultXhrHeader: false.
I hope help you.
I would like to suggest you a different approach because sending login credentials as GET parameter to remote server over http is not a good idea, instead you should use POST method over HTTPS. Now you would think JSONP doesn't support POST so how can I do this, but if you are going to install your app on Phone or iPad it would do remote call from browser without using JsonP, which means you can use normal AJAX proxy to do whatever you want. Check this out:
How to use json proxy to access remote services during development
Which means this should work:
var obj = new Object();
obj.userId = username;
obj.password = password;
var data = Ext.JSON.encode(obj);
Ext.Ajax.request({
url : 'https://login_url',
method : "POST",
headers: {
'Content-Type': 'application/json'
},
params : data,
useDefaultXhrHeader : false,
withCredentials: true,
success : function(response) {
},
failure : function(response) {
}
});
I am just learning sencha touch. I am trying to retrieve data form a server (following the getting started example). I am trying to print the response to the console in a success callback. Here is the code I am attempting to use, but nothing is being printed to the console.
proxy: {
type: 'jsonp',
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
},
listeners: {
success: function(response) {
console.log(response)
}
}
so, what is the proper syntax for a success callback so that I can do some stuff with the response like print it in the console?
Thanks!
Change this
rootProperty: 'responseData.feed.entries'
for this:
root: 'responseData.feed.entries'
Or could you change proxy: {type: 'jsonp' ... } for proxy: {type: 'ajax' ... } plus above.
I hope these helps.
I'm working on a Sencha Touch app and I want to use OData so I have been playing around with the netflix Odata service. When I send my request with JSONP in Sencha I can see the request come back when I trace it, however my callback function is never getting called. Can anyone help? Here is my code.
var blah = function () {
Ext.util.JSONP.request({
url: 'http://odata.netflix.com/catalog/Titles()',
callbackKey: 'callback',
params: {
$format: 'json',
$top: '10',
$filter: "startswith(Name,'C')",
$select: "ShortName"
},
callback: function (result) {
alert('asdf');
var data = result;
if (data) {
alert('data');
} else {
alert('There was an error during retrieving data.');
}
}
});
}
var button = new Ext.Button({
text: 'Ajax',
listeners: {
'tap': blah
}
});
Thanks in advance
If you're getting a syntax error on the server response quotes, this is a known issue described here for which there is an available update.
The server is returning XML, not JSON data.