If you don't know what I mean, post some of your code. I could describe it more detailed.
Recently I've made something similar, a page where a barcode can be scanned and the corresponding product data is shown. The form shouldn't be used as a standard HTML form where you send the data to a second (php) page. Instead you first disable the form or use the jQuery preventDefault() method to stop the form from performing the standard action. Then you get the value(s) of the form data, in your case the user ID. The next step is to send the data via Ajax to the php script on the server ($.ajax();). If you let your php script output HTML or JSON data you can use this data in the ajax .done(function(data){...}); section.
To use this combined with facebox there are two possibilities. The first one is to make a div on your page that is on default set to display:none;. When your ajax request is done you first put the data in the right containers in this hidden div and then fire facebox (something like $.facebox("#hiddendiv")) to present the data to the user.
The other way is to use the ajax method in the facebox api like I mentioned in my previous reaction. The first part of your script where you retrieve the user ID will be the same, but you replace the ajax request with the facebox function. The advantage of this method is that during the ajax call a facebox pops up and shows the user a loading gif. The downside is that the result coming from your php page should be html to be put in the facebox. This way you have html code for one page in two seperate files, not something I usually like to do. Besides that you could implement your own loading icon with 2 simple lines of jQuery.
On my page for handling barcodes the script looks like this (don't mind the timer code, it is to prevent the event binder from firing the function after only a single character is scanned):
$("#barcode").bind('input propertychange',function(){
var delay = 100; // in ms, 2000 = 2 sec
clearTimeout($(this).data('timer'));
$(this).data('timer', setTimeout(function(){
$(this).removeData('timer');
var code = $("#barcode").val();
scan(code, 'scan');
$("#barcode").val('');
}, delay));
});
function scan(barcode, method){
$("#scanResult span").each(function(){$(this).hide();});
$("#img_ok").hide();
$("#img_error").hide();
$("#img_loading").show();
var type = '';
if (method=='scan') {
if (barcode.length==7 && barcode.substr(0,1)=='P') {
type='pt_nr';
}
else if (barcode.length == 13) {
type='ISBN';
}
else {
$("#scanResult #notFound").show();
$("#img_loading").hide();
return false;
}
} else {
type='unknown'
}
// make ajax request
$.ajax({
type: "POST",
dataType: "json",
url: "resources/scripts/smdetails.server.php?key=9763jhh12",
data: { field: type, query: barcode}
}).done(function( res ) {
if (res.numrows==0){
$("#scanResult #notFound").show();
$("#img_loading").hide();
} else if (res.numrows>1){
$("#scanResult #moreThenOne").show();
$("#img_loading").hide();
} else {
// put data in table
$("td#art_nr").text(res.art_nr);
$("td#title").text(res.title);
// etc..
$.facebox({ div: '#result' });
}
});
}
Like I mentioned before, if you have more questions just post some more of your code.
Good luck!
Op vrijdag 10 mei 2013 16:11:47 UTC+2 schreef Thomas de Jesus het volgende: