fancybox.close() and open another fancybox - fancybox

Is the first time that I'am using this forum.
My problem is that I want to close a fancybox to open another fancybox. And for that I am using in my code the parent.$.fancybox.close() to close the Fancybox Iframe Window. When the user click in the Add to cart button. The fancybox close and my program in js STOP running. Example:
$(x).click(function(){
parent.$.fancybox.close();
idCombination = $('#idCombination').val();
$.ajax({
type: "POST",
url: baseUri + '?rand=' + new Date().getTime(),
data: 'controller=cart&add=1&ajax=true&qty=' + $('#quantity_wanted').val() + '&id_product=' + id_product + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
beforeSend: function() {
$('#loading_img').show();
},
success: function(q) {
$.ajax({
type: "POST",
url: path + "ajaxcart/pop_up.php",data:'referer='+document.referrer,
beforeSend: function() {
$(".shop").show();
$('#loading_img').show();
},
success: function(res) {
$(".shop").show();
$("#shopping").show();
$('#loading_img').hide();
$('#shopping').html(res);
}
});
}
});
$("html, body").animate({scrollTop: 300}, "slow");
return false;
});

Related

How to restrict user from submitting a form twice in sharepoint?

I'm working on a sharepoint forms
And I need to block edition for users after they submitted a date (data format), but I don't know if sharepoint allows it
Someone knows how can I do it?
For OOB list form, you could use presaveaction to do client validation.
In this function, you could call rest api to check whether the item submitted already, if submitted, return false then the form won't be saved.
Sample demo:
<script type="text/javascript" src="/_layouts/15/JS/jquery.min.js"></script>
<script type="text/javascript">
function PreSaveAction() {
var check = false;
var listid = _spPageContextInfo.pageListId.replace('{', '').replace('}', '');
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists(guid'" + listid + "')/items",
type: 'GET',
async: false,
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
},
success: function (data, textStatus, jqXHR) {
var count = data.d.results.length;
if (count < 5) {
check = true;
} else {
alert('over max items');
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(textStatus);
}
})
return check;
}
</script>

Facing issue as 404 while Ajax call in typo3

I am new in typo3 and used the ajaxselectlist extension but while the time usage I am facing 404 not found an error.
Below code is fetch from ajaxselectlist/Resources/Templates/OptionRecord/List.html
<script>
jQuery(document).ready(function ($) {
var form = $('#ajaxselectlist-form');
var selectForm = $('.ajaxFormOption');
var controllerpath = $("#uri_hidden").val();
var resultContainer = $('#ajaxCallResult');
var service = {
ajaxCall: function (data) {
console.log("---->"+data.serialize());
$.ajax({
url: controllerpath,
cache: false,
data: {'uid':'1'},
success: function (result) {
resultContainer.html(result).fadeIn('slow');
},
error: function (jqXHR, textStatus, errorThrow) {
resultContainer.html('Ajax request - ' + textStatus + ': ' + errorThrow).fadeIn('fast');
}
});
}
};
form.submit(function (ev) {
ev.preventDefault();
service.ajaxCall($(this));
});
selectForm.change(function () {
resultContainer.fadeOut('slow');
form.submit();
});
selectForm.trigger('change');
});
</script>

Reading ListItems inside folders from Sharepoint list( not library)

How to read sharepoint list items from a specific folders using Javascript/Jquery through JSOM or REST?
Using JSOM or CSOM, you need to specify 'FileDirRef' property in CAML Query, and add 'RecursiveAll' scope:
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(
'<View Scope="RecursiveAll"> " +
"<Query>" +
"<Where>" +
"<Eq>" +
"<FieldRef Name="FileDirRef" />" +
"<Value Type=\"Text\">yourFolderPath</Value>" +
"</Eq>" +
"</Where>" +
"</Query>" +
"</View>');
function GetFolders() {
var oWeb = _spPageContextInfo.webAbsoluteUrl;
var URLC = oWeb + "/_api/web/lists/getByTitle('ListName')/items";
$.ajax({
url: URLC,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
async: false,
cache: false,
success: function (data) {
$.each(data.d.results, function (index, item) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('ListName/ListFolder)/listitemallfields/",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
async: false,
cache: false,
success: function (data) {
}
});
})
},
error: function (data) { }
});
}
You can use REST API to read list items from a specific folders using getfolderbyserverrelativeurl.
Refer below Code :
var folderRelativeUrl = "Relative_URL_Of_Your_Folder"; //here specify relative URL of your folder (e.g. '/Shared Documents')
getItemFromFolder().then(getItemFromFolderSuccess, getItemFromFolderFailed);
function getItemFromFolder(){
return $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('" + folderRelativeUrl + "')/files?$expand=ListItemAllFields",
type: "GET",
headers: {
"Accept": "application/json;odata=verbose"
}
});
}
function getItemFromFolderSuccess(data){
// success handler
var response = data.d.results; // This is Response Object from Server
}
function getItemFromFolderFailed(error){
// error handler code
}

PhantomJS - Upload file to facebook

I'm trying to use PhantomJS 2.1.1 to update my profile picture on facebook. I'm able to log in, and navigate to the page where I should upload the picture, but page.uploadFile is just not working.
The last screenshot (page.render('end.png')) shows facebook alert "Please choose file to upload" confirming that page.uploadFile didn't work.
Any idea on how I can achieve this?
upload_page2.png
end.png
var args = require('system').args;
var page = require('webpage').create();
page.open('https://m.facebook.com', function(status){
if(status === "success"){
setTimeout(function(){
page.evaluate(function (args) {
document.getElementsByName("email")[0].value = args[1];
document.getElementsByName("pass")[0].value = args[2];
document.getElementById("loginbutton").click();
}, args);
}, 2000);
setTimeout(function(){
page.render('logged.png');
page.open('https://m.facebook.com/photos/upload/?profile_pic&upload_source=profile_pic_upload&profile_pic_source=tagged_photos_page', function(status){
});
}, 4000);
setTimeout(function(){
page.render('upload_page1.png');
page.uploadFile('input[name=file1]', 'http://proprofs-cdn.s3.amazonaws.com/images/games/user_images/misc/4288844624.png');
}, 6000);
setTimeout(function(){
page.render('upload_page2.png');
page.evaluate(function (args) {
var a = document.querySelectorAll('[type="submit"]');
a[0].click();
}, args);
}, 10000);
} else {
console.log("Error opening url \"" + page.reason_url + "\": " + page.reason);
}
setTimeout(function(){
page.render('end.png');
phantom.exit();
}, 15000);
});

Send a wall post using Jquery's AJAX (Post)

I'm trying to post a wall message from a local desktop application (I can't use the FB JS SDK).
Here's a a snippet of my code
var url = "https://graph.facebook.com/me/feed";
var params = "access_token=" + token + "&message=" + encodeURI(text);
$.ajax({
crossDomain: true,
data: params,
dataType: "jsonp",
url: url,
type: 'POST',
success: function (data) {
if (callback) {
var isOK = (data && data.id && !data.error);
callback(isOK, data);
}
},
error: function (data, e1, e2) {
}
});
The request ignores the message parameter.
I receive a list of feeds as it were a GET request.
I've tried to set the parameters as map but it didn't help.
BTW - when using CURL (in C++) i manage to post the data correctly.
Any ideas why it ignores the parameters?
I would put the "params" into the data element like so:
var url = "https://graph.facebook.com/me/feed";
$.ajax({
crossDomain: true,
data: { access_token: token, message: text },
dataType: "jsonp",
url: url,
type: 'POST',
success: function (data) {
if (callback) {
var isOK = (data && data.id && !data.error);
callback(isOK, data);
}
},
error: function (data, e1, e2) {
}
});
Let jQuery encode the parameters from there.
Below worked fine in Jquery 1.6.4 + jquery.mobile-1.0rc2 by setting $.mobile.allowCrossDomainPages = true; in mobileinit bind
$.ajax( {
url : "https://graph.facebook.com/me/feed",
type : "POST",
data : "access_token=" + your_access_token + "&message=my first wall post",
cache : false,
success : function(res) {
if (!response || response.error) {
alert("Couldn't Publish Data");
} else {
alert("Message successfully posted to your wall");
}
},
error : function(xhr, textStatus, errorThrown) {
alert(xhr.responseText);
}
});