Posts

javascript - PHP & Jquery Ajax, json, get data in the ajax destination file -

i need send array in php trough ajax different server, trying following. array encoded json_encode : [ {"id":"1","name":"avocado toast tartine","qty":"1","price":"88.00","spec":""}, {"id":"16","name":"add berries","qty":"1","price":"48.00","spec":""} ] so in origin file have: <script> var cart = <?php echo $cart; ?>; //this array above $.ajax({ url: 'https://www.mydestinationurl.com.hk/new/admin/do_lpq_order.php', crossdomain: true, type: 'post', data: cart }).done(function(data) { console.log(data); }); </script> and in destination file have this: <?php switch ($_server['http_origin']) { case 'http://localhost': case 'https://...

managing multiple values in android -

i doing project on ecommerce app. in dashboard activity getting username value login activity , mobile number main activity. want check 2 values , set in text view according incoming values. how can achieve? you either store them in sqlite database or similar, or store them in sharedpreferences . you can more options here

Why does this JavaScript code make the entire array point to the same object? -

in book javascript: parts , there code on page 64: for (i = 0; < n; += 1) { my_array[i] = []; } // note: array.dim(n, []) not work here. // each element reference same // array, bad. why each element in array point same object? seems me line my_array[i] = []; reevaluated each loop, causing new empty object created. what're rules of getting reference same object versus new one? how make different empty array every loop? edit: reading people's responses, read paragraph wrong. answers! this loop new reference each time. run it, mutate 1 of arrays , you'll see 1 changes. the problem more array.dim method. imagine it's implemented this: array.dim = function(n, init) { var arr = []; var i; (i = 0; < n; += 1) { arr[i] = init; } return arr; } using literal array syntax create new reference array, method uses same reference populate each value of resulting array. it might easiest compare 2 way. var init = []; (i = 0; < ...

bytebuffer - Read and write to a particular line in large textfile java -

i'm using stream read particular line file , of pre-calculated byte position value i'm using filechannel , bytebuffer write same location in big file. editing values in textfile. //read particular line stream<string> lines = files.lines(paths.get('pathtofile')); string text = lines.skip(linenumber).findfirst().get(); // modify text example text.replace("r",r); // re-write same position after manipulating same text randomaccessfile file = new randomaccessfile('pathtofile', "rw"); filechannel channel= file.getchannel(); bytebuffer buf = bytebuffer.allocate(50); buf.put(text) buf.flip() channel.position(pre_calculated_position); while(buf.hasremaining) channel.write(buf) channel.close(); buf.clear(); file.close(); i'm wondering if there cleaner or better way same without reading line line? thanks

c# - How to prevent Unity overwriting existing mappings with AutoRegistration -

unity 3 offers new capabilities autoregistration (registration convention) such as: container.registertypes( allclasses.fromloadedassemblies(), //uses reflection withmappings.frommatchinginterface, //matches interfaces implementations name withname.default); this code register types implement named interfaces, against interfaces. example, class myservice : imyservice registered automatically though had written following: container.registertype<imyservice, myservice >(); my question: if want of time, want choose different implementation 1 of interfaces, though named implementation exists? see: patterns , practices on codeplex an important article read explaining why want jeremy miller's convention on configuration article what stops overriding automated mapping custom set loaded configuration (which - if empty - means no default mapping overridden): // have auto registration container.registertypes( allclasses.fromloadedassemblies...

c# 4.0 - devenv /runexit command does't closes visual studio instance? -

i'm in process of automating applications. i'm using... devenv.exe /runexit "solutionfile\path\filename.sln" i'm running applications. if exceptions occurred in above process, visual studio doesn't exit , automation returns success. i've searched other command line switches couldn't found solution this. please share solutions this?

MATLAB "Subscript indices must either be real positive integers or logicals" -

in matlab examples page computer vision system toolbox, there code object detection in cluttered scene using point feature matching. running same code on system, giving error "subscript indices must either real positive integers or logicals" code tries match similarity between 2 images. i1 = rgb2gray(imread('kitchen.jpg')); i2 = rgb2gray(imread('loops.jpg')); points1 = detectsurffeatures(i1); points2 = detectsurffeatures(i2); [features1, valid_points1] = extractfeatures(i1, points1); [features2, valid_points2] = extractfeatures(i2, points2); indexpairs = matchfeatures(features1, features2); matchedpoints1 = valid_points1(indexpairs(:, 1), :); //error matchedpoints2 = valid_points2(indexpairs(:, 2), :); figure; showmatchedfeatures(i1, i2, matchedpoints1, matchedpoints2); i new matlab , trying understand concepts got stuck in this. appreciated. thank you. i tried code (with slight changes) sample image , worked: //open image = rgb2gray(imre...