javascript,jquery,http,post,multipartRelated issues-Collection of common programming errors
maryisdead
javascript events javascript-events mootools
I seem to get something fundamentally wrong. I have this HTML<div id=”thumbnails”><a href=”#image-0″><img src=”blabla-1.jpg” /></a><a href=”#image-0″><img src=”blabla-1.jpg” /></a><a href=”#image-0″><img src=”blabla-1.jpg” /></a> </div>and this JavaScript (MooTools library in use)document.id(‘thumbnails’).getElements(‘a’).each(function(image_link, image_link_index) {image_link.addEvent(‘click’, function(evt){if (evt.target.get(‘ta
Carm
javascript
I am trying to solve this problem on Talentbuddy, but I’m not sure if I’m even on the right track. I was wondering if someone could point me i the right direction? Pair productWrite to the standard output the greatest product of 2 numbers to bedivisible by 3 from a given array of pozitive integers.Example input: 6, 8, 8, 7, 2, 5Example output: 48function max_prod(v) { // Write your code here // To print results to the standard output please use console.log() // Example: console.log(“Hello world!
Daniel Imms
javascript jquery javascript-events mouseevent mousedown
html code:<div class=”wrap”> </div>js code:$(document).ready(function() { $(“body”).mousedown(function(event) {switch (event.which) {case 1:alert(‘hello!’);break;case 2:alert(‘forbid the key’);break;default:alert(‘hehhe’);} });when i open the page then press the left mouse key, it doesn’t alert hello. why?thank you.when i press the right key, i want to alert(“forbid the left”). then after 2 minute. then close the page. how to add the function to the case 2. thank youps: this is i wan
WyoBuckeye
javascript object
If I declare an object as follows:var foo.bar = new Object;Does that automatically make foo an object? If not and I want both foo and foo.bar to be objects do I need to use the following code:var foo = new Object; var foo.bar = new Object;And if I create these two objects as above, is there a parent/child relationship between them or are they completely separate entities?I apologize for the simple nature of my question, but I am trying to more fully understand the various ways data can be struc
tattooedgeek
javascript ruby-on-rails
I have a pretty simple form as I’m just really playing with RoR at the moment, just collecting some data and plunking it in the DB, nothing exciting just basic CRUD. However, I am wanting to put a sum field in the footer of my table, but I’m not finding anything even close on the web. Is this not possible in RoR? Seems like a pretty simplistic task, but I’m sure my noobiness in Rails isn’t helping matters anyway. :)<tbody><% @labors.each do |labor| %><tr><td><%= lab
remyremy
javascript php json
I have the following JSON reply from a PHP file:[{“color”: “black”,”product_name”: “Prod2″,”revision”: “apps/”},{“color”: “green”,”product_name”: “Prod1″,”revision”: “dev/”} ](tested OK on JSONLint)And Javascript:$(document).ready(function(){ $(‘.target’).keyup(function() {var package_name = “name”;var package_version = “version”;var filter_results = “filter”;$.post(‘includes/package_filter.php’, { package_name: package_name, package_version: package_version, filter_results: filter_results },
kgiannakakis
javascript jquery
I’ve got a bit of a problem with a jquery menu. I works just fine, but if you hover over the buttons 3 or 4 times, the menu will expand 3 or 4 times repetitively, and all you can do it wait for it to quit. Can somebody please tell me how to stop this? Here’s the javascript I’m using:<script type=”text/javascript”> $(function () {$(‘#dropMenu .level1 .submenu.submenu’).hover(function() { $(this).find(‘ul.level2,.level3 li,.level4 li,.level5 li,.level6 li’).stop(true, true).hide(1000); $(thi
H.Muster
javascript jquery dom event-handling dynamically-generated
I’ll try and explain what I’m trying to do as clearly as I can and hopefully people’ll be able to understand the issue.$(document).ready(function() {$(‘body’).on(‘click’, ‘.mainNav’, function() {var href = $(this).attr(‘href’);$(‘body’).load(href);}); });This is the bit of code which has been causing me trouble. Basically what it’s -supposed- to do is grab the ‘href’ attribute from a div and then load that to replace the current content of the body tag.This works the first time but when the new
likeitlikeit
php javascript json
I have a PHP script that is building the header portion of an HTML(5) document. Part of what is being emitted is something like this$rtn = <<<RTN <script type=’text/javascript’> var _scrolls = {“alpha”:{“cursorborder”:”1px dashed rgba(200,13,57,1)”}}; var _floors = new Array(10000,{$mqt},{$mqf}); </script> RTN;The JSON is valid – at least, JSONlint.com seems to think so. However, in my browser (Chrome on Windows) this throws up an error Uncaught Syntax Error: Unexpected to
Tom Murray
javascript html5 graphics canvas
I have the following code for writing draw calls to a “back buffer” canvas, then placing those in a main canvas using drawImage. This is for optimization purposes and to ensure all images get placed in sequence.Before placing the buffer canvas on top of the main one, I’m using fillRect to create a dark-blue background on the main canvas.However, the blue background is rendering after the sprites. This is unexpected, as I am making its fillRect call first.Here is my code:render: function() {thi
bjarne_f
jquery fancybox
Is there a way to translate the tooltips in fancybox, e.g. the tooltip on the close button?I have done this in the afterShow callback to change the value to Danish and seems to work.. or is there a better way to change it?<script type=”text/javascript”>$(document).ready(function() {$(“a.mapoverlay”).fancybox({width : ‘90%’,height : ‘90%’,fixed: false,autoSize : false,autoCenter : true,afterLoad : function() {loadMap();},afterShow : function() {$(“a.fancybox-close”).attr(“title”, “Luk”)
Daniel Imms
javascript jquery javascript-events mouseevent mousedown
html code:<div class=”wrap”> </div>js code:$(document).ready(function() { $(“body”).mousedown(function(event) {switch (event.which) {case 1:alert(‘hello!’);break;case 2:alert(‘forbid the key’);break;default:alert(‘hehhe’);} });when i open the page then press the left mouse key, it doesn’t alert hello. why?thank you.when i press the right key, i want to alert(“forbid the left”). then after 2 minute. then close the page. how to add the function to the case 2. thank youps: this is i wan
sevargdcg
jquery ajax asp.net-mvc-4 kendo-ui kendo-grid
I am using the Kendo UI grid via the MVC Helper object. If an error occurs in the ajax call (ie. web server is not available), the request returns an error code, however the Kendo UI grid does not respond and just continues to act as though there is no data being returned.@(Html.Kendo().Grid<ProcessInformation>().Name(“Grid”){Edited for brevity}.DataSource(datasource => datasource.Ajax().Read(read => read.Action(“SearchProcesses”, “SystemProcess”).Data(“searchSerialize”)).PageSize(10
kgiannakakis
javascript jquery
I’ve got a bit of a problem with a jquery menu. I works just fine, but if you hover over the buttons 3 or 4 times, the menu will expand 3 or 4 times repetitively, and all you can do it wait for it to quit. Can somebody please tell me how to stop this? Here’s the javascript I’m using:<script type=”text/javascript”> $(function () {$(‘#dropMenu .level1 .submenu.submenu’).hover(function() { $(this).find(‘ul.level2,.level3 li,.level4 li,.level5 li,.level6 li’).stop(true, true).hide(1000); $(thi
Gareth Gillman
jquery
I am trying to add a load more function via jQuery which partially works, in that it shows the read more, but it should be hidden on any elements without an LIThe second part increases the height of the UL element when load more is clicked, but this happens on every ul and not where the load more was clicked$(‘.loadMore’).hide(); $(“.box-category li ul li”).each(function() { if ( $(this).has(‘ul’).length ) {$(this).find(‘.loadMore’).show();$(this).find(‘ul’).css({‘overflow’ : ‘hidden’, height :
H.Muster
javascript jquery dom event-handling dynamically-generated
I’ll try and explain what I’m trying to do as clearly as I can and hopefully people’ll be able to understand the issue.$(document).ready(function() {$(‘body’).on(‘click’, ‘.mainNav’, function() {var href = $(this).attr(‘href’);$(‘body’).load(href);}); });This is the bit of code which has been causing me trouble. Basically what it’s -supposed- to do is grab the ‘href’ attribute from a div and then load that to replace the current content of the body tag.This works the first time but when the new
Josh M.
jquery ajax urlencode
When passing an object as the data to the ajax call, I am getting some unexpected results. For some reason, jQuery is adding square brackets to my parameter names if their value is an array. For instance…var obj ={name: “John Doe”,courses: [ 1, 2, 4 ]};…becomes name=John+Doe&courses[]=1&courses[]=2&courses[]=4 instead of name=John+Doe&courses=1&courses=2&courses=4.Why is jQuery adding the square brackets?Here is a working example: http://jsfiddle.net/BrHSy/Update:I ex
Jan Hommes
jquery
I’m wondering why this method:window.location.hash = JSON.stringify($(“body”)[0]);Adds some kind of jquery-id to the hash. It looks like this:foo.htm#{“jQuery18305139440292647334”:13}What is this “id” (how is it called?) and is there any way to get back to the DOM element from this id? Is this id consistent after page reload?
Dan Holevoet
jquery google-app-engine google-api-js-client
In my web application, I allow users to login using the auth command in the API Client Library but I cannot find a Logout option for the Google API JavaScript Client Library.Can any one suggest how can i Logout of my application as well as google account??My Login Code is:var OAUTHURL = ‘https://accounts.google.com/o/oauth2/auth?’; var VALIDURL = ‘https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=’; var SCOPE = ‘https://www.googleapis.com/auth/userinfo.profile’; var CLIENTID = googleAP
cbuckley
php jquery
I searched and read most of the related topics, but they weren’t what I was looking for.I’ve a JSON enocded string with json_encode PHP function:{“casts”:[“Matthew Modine”,”Adam Baldwin”,”Vincent D’Onofrio”],”year”:1987}I’m working with jQuery to put the values in appropriate fields too, in the case of testing I did the below:<script> var obj = jQuery.parseJSON(‘<?=$data?>’); console.log(obj); </script>Suppose that $data is this:$data = <<<END {“casts”:[“Matthew Modine
Lucifer
http networking blackberry
I am using Httconnection for connecting to webserver , somtimes request fails causing EOFException when calling httpconnection.getResponseCode().I am setting the following headers while making the connectionHttpConnection httpconnection = (HttpConnection) Connector.open(url.concat(“;interface=wifi”)); httpconnection.setRequestProperty(“User-Agent”,”Profile/MIDP-2.0 Configuration/CLDC-1.0″); httpconnection.setRequestProperty(“Content-Language”, “en-US”);I am closing all the connections after proc
B Seven
ruby http rspec tdd bdd
Yes, I know it is best to use webmock, but I would like to know how to mock this method in RSpec:def method_to_testurl = URI.parse urireq = Net::HTTP::Post.new url.pathres = Net::HTTP.start(url.host, url.port) do |http|http.request req, foo: 1endres endHere is the RSpec:let( :uri ) { ‘http://example.com’ }specify ‘HTTP call’ dohttp = mock :httpNet::HTTP.stub!(:start).and_yield httphttp.should_receive(:request).with(Net::HTTP::Post.new(uri), foo: 1).and_return 202method_to_test.should == 202 endT
David-SkyMesh
perl http asynchronous anyevent worker-pool
I’m trying to write a script which will download at most N files simultaneously via HTTP. I’ve previously used AnyEvent::Worker::Pool to manage a pool of BLOCKING tasks. I’ve also used AnyEvent::HTTP in combination with AnyEvent->condvar to manage NON-BLOCKING downloads individually. I thought that it should be pretty simple to combine the two approaches so that AnyEvent->condvar makes AnyEvent::HTTP::http_get look BLOCKING from the perspective of AnyEvent::Worker::Pool.However, I’m getting some
user1618143
html http firefox https youtube
I’m working on a site that requires a login and includes embedded Youtube videos. Because of the login, I need to get SSL working, which it largely is. I’m hitting an unexpected problem with the Youtube embeds, though. It’s easy enough to point at https://www.youtube.com, but Firefox still complains that there’s unencrypted content on an encrypted page. According to Firebug, the only unencrypted load was from http://[stuff].youtube.com/videoplayback?[more stuff].Now, it’s perfectly understandabl
Kai Sellgren
http nginx websocket
I’m trying to proxy WebSocket + HTTP traffic with nginx.I have read this: http://nginx.org/en/docs/http/websocket.htmlMy config looks like:http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;gzip on;map $http_upgrade $connection_upgrade {default upgrade;” close;}server {listen 80;server_name ourapp.com;location / {proxy_pass http://127.0.0.1:100;proxy_http_version 1.1;proxy_redirect off;proxy_set_header Host $host;pr
Thomas Watson
api http rest http-headers authorization
I need to authenticate a client when he sends a request to an API. The client has an API-token and I was thinking about using the standard Auhtorization header to send the token to the server.Normally this header is used for Basic and Digest authentication. But I don’t know if I’m allowed to customize the value of this header and use a custom auth-scheme, e.g:Authorization: Token 1af538baa9045a84c0e889f672baf83ff24Would you recommend this or not? Or is there an better approach to sending the tok
Romulo Ceccon
xml http validation xml-schema http-status-codes
Among the data my application sends to a third-party SOA server are complex XMLs. The server owner does provide the XML schemas (.xsd) and, since the server rejects invalid XMLs with a meaningless message, I need to validate them locally before sending.I could use a stand-alone XML schema validator but they are slow, mainly because of the time required to parse the schema files. So I wrote my own schema validator (in Java, if that matters) in the form of an HTTP Server which caches the already p
tstenner
java xml http scala soap
I’m trying to write a program in Scala, that will accept SOAP-requests, get the response from the real server (or read it from the local disc) and return the data to the original client.I’m new to the java/scala ecosystem, so I have no clue, what libraries to choose. I heard Scala’s XML-handling is quite nice, so I don’t know, whether I should use some enterprisey soap-library/framework like jax-ws, jboss-ws, axis, cxf, xmlbeans, etc.Basically, I just needa library, that accepts the requests (cu
James McMahon
asp.net http
Ok, I know the difference in purpose. GET is to get some data. Make a request and get data back. POST should be used for CRUD operations other than read I believe. But when it comes down to it, does the server really care if it’s receiving a GET vs. POST in the end?
user3084182
node.js http get
I have a piece of code that’s supposed to do a http get request. The program exited successfully without error, but I didn’t see any response and it didn’t even go inside the callback function! At first I thought it’s because http is asynchronous and put a large loop in the end but that didn’t work either. Does anyone know this issue? Only the first console log sendHttpRequest and 444 gets printed. I also tried the http.get but it didn’t work either.function sendHttpRequest (url, callBack) {cons
user1363445
python post tornado
I’m trying to use Tornado to start a server and post a string to it. I’ve found lots of examples of how to write the post method in the handler class, but no examples of how to write the post request. My current code does cause the post method to execute, but get_argument isn’t getting the data–it just prints the default “No data received” every time. What am I doing wrong?My code looks like this:class MainHandler(tornado.web.RequestHandler):def post(self):data = self.get_argument(‘body’, ‘N
fran
xml http windows-phone-7 post httpwebrequest
I’m struggling to get it work but it seems doing unexpected stuff, what’s wrong?string xmlToSend = “<elementOne xmlns=\”htt..mynamespace\”>…….</elementOne>”; request = (HttpWebRequest)WebRequest.Create(address);request.Method = “POST”;request.ContentType = “text/xml; charset=utf-8”;request.Headers[“Content-Length”] = xmlToSend.Length.ToString();_postData.Append(string.Format(“{0}”, xmlToSend));request.BeginGetRequestStream(new AsyncCallback(RequestReady), request);…. }and the B
user3056837
json parsing rest post kinvey
for anyone that is working with kinvey console – I am trying to make simple post request via the API console to a custom endpoint but getting jsonParse error. The enpoint code is – function onRequest(request, response, modules){modules.logger.info(request.body.name + ” has ” + request.body.eyes + ” eyes.”);response.complete(200); }The request – POST https://baas.kinvey.com/rpc/kid_TVdEjbOoXi/custom/test HTTP/1.1 Authorization: “xxx” //my authorization number X-Kinvey-API-Version: 3 Content-Type
w0rldart
post parameters nginx laravel
I just set up Nginx, and I’m trying to use it to host a Laravel app, but I ran into 2 problems.For GET method, I always get an extra parameter in my inputs.Using PostMan (Chrome) to do my testings, I set the destination URL and my desired parameters and send the request. The output that I get, it always includes the REQUEST_URI which it shouldn’t. Example output:.Array ([/api/user] => // This shouldn’t be here[test] => test )My parameters (the above) will NOT show for DELETE or PUT, at all
meagar
php sql post insert
I am trying to INSERT some data into a database. I can do this on one FIELD just not on multiple. It seems to be a simple syntax issue. The error I get is:Parse error: syntax error, unexpected ‘,’, expecting ‘]’The error is on the INSERT line:<?php $con = mysql_connect(“local”,”username”,”password”); if (!$con) {die(‘Could not connect: ‘ . mysql_error());}mysql_select_db(“npsreviews”, $con);$sql=”INSERT INTO burkett (DATE, STORE, 5STAR, 4STAR, 3STAR, 2STAR, 1STAR, TOTAL, NPS) VALUES (‘$_PO
David Hamilton
php rest post curl
I am trying to post XML data to SmashFly using cURL but I keep getting this error:The incoming message has an unexpected message format ‘Raw’. The expected message formats for the operation are ‘Xml’, ‘Json’I’ve tried several different variation of this line:curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘contentType:text/xml’)); but I always get the “message format was raw” Here is the complete posting code:$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRA
Codemator
php jquery ajax jquery-ajax post
I am new to Jquery. I am trying to post a form to a php file using Jquery Post, I did a var_dump($_POST) in the php file but i can see only an empty array ( saw using firebug net), but i am coming back to the success function of Jquery. May be I am doing some thing silly..All the Javascript behaviour is working as expected except this problem. Somebody please help$(document).ready(function() {//if submit button is clicked$(‘#submit’).click(function () { //show the loading sign$(‘#example’)
dplante
php facebook post
I am trying to do a simple post to facebook, I got same sample to do a postcode and I changed it a little. I get the following errorParse error: syntax error, unexpected ‘;’ in /home/consult/public_html/projects/facebook/index.php on line 13the line is’access_token’=>;urlencode($code),the code:<?php //set POST variables $url = ‘https://graph.facebook.com/arjun/feed’; $code=”testing”; $message=”Test”; $fields = array(‘access_token’=>;urlencode($code),’message’=>;urlencode($message),);
Explosion Pills
http post get http-post http-get
Simply put, I have a website where you can sign up as a user and add data. Currently it only makes sense to add specific data once, so an addition should be idempotent, but theoretically you could add the same data multiple times. I won’t get into that here.According to RFC 2616, GET requests should be idempotent (really nullipotent). I want users to be able to do something like visithttp://example.com/<username>/add/?data=1And this would add that data. It would make sense to have a PU
JasCav
jquery post
I am trying to perform the following fadeIn/fadeOut action within the jQuery $.post function.$.post(‘Scenario/SaveScenario’, function (data) {$(‘<div class=”save-alert”>The current scenario has been saved.</div>’).insertAfter($(‘.buttons’)).fadeIn(‘slow’).animate({ opacity: 1.0 }, 2000).fadeOut(‘slow’, function () {$(this).remove();}); });However, this does not work and (apparently) nothing happens. (I put a breakpoint inside the function within Firebug and it is never reached.) The
skaffman
jquery multipart plupload
Seems Plupload is a great tool. But I’m stuck in a simple problem here. I have set multipart = false (I don’t want to send data in chunks), however, I want to show the percentage uploaded. But it shows no % uploaded and only shows 100% at the end of upload. Here is my code.$(function() {var pluploader = new plupload.Uploader({runtimes : ‘flash’, //flash,gears,flash,silverlight,browserplus,html5browse_button : ‘img_video_upload’,container : ‘video_upload_container’,max_file_size : ‘3gb’,//chunk_
Amulya Khare
android nullpointerexception sms multipart
All of a sudden my widely-used app has started crashing when attempting to send a multipart text. This is after 1000s of users, so we are not looking at a simple bug (I think!). Its definitely correlated to 4.1.2, definitely 4.x versions.My desperate work-around has been to trap the NullPointerException and then send this multipart as multiple standard (< 160) texts (ugh, I know). The stack trace is below, even looking into the Android source hasn’t helped.java.lang.NullPointerException at an
Adam Davis
user415217
exception grails upload multipart
I have a very basic upload action in my controller. It looks something like the action below. It works great. The only problem I’m seeing is when a user cancels an upload (or hits stop on their browser). I am able to recover correctly, but not before seeing an uncaught exception in my logs. The exception is listed below. Any help or feedback on how to correctly catch the uncaught exception here would be appreciated. Seems like it’s happening somewhere between the client and the controller
treznik
php api twitter oauth multipart
I’ve been trying to find the best OAuth PHP lib for Twitter for hours. the TmhOAuth by Matt Harris seems kinda bloated (no offence) and started shooting PHP Warnings and Strict Standards notices right after I “installed” it.All I want is to update my bg photo through the API. Just mine, so there is no need for any login and callbacks of any kind, all the keys are hard-coded.In the end I found out about PHP’s own thing: http://php.net/manual/en/book.oauth.phpSeemed cool because everything has 4 l
MarcWan
mysql node.js express multipart
I’m still reasonably new to the whole node thingie, so please forgive me if this is rampantly stupid, but:If I call query() on a node-mysql client object, I can no longer get the body of a request object from within my web app (express).my basic POST / PUT pattern requests requiring user auth is:_db_client = connect_to_db_server(); app.post(“/some/path”, function (req, res) {_db_client.query(“SELECT * FROM Users WHERE username = ?”,[ http_basic_auth.username ], function (err, results) {if (err !
james.garriss
javascript jquery http post multipart
I’m trying to make a HTTP POST call with multipart/form-data , using jQuery:$.ajax({url: ‘http://localhost:8080/dcs/rest’,type: ‘POST’,contentType:’multipart/form-data’,data: ‘dcs.source=boss-web&query=data&dcs.algorithm=lingo&dcs.output.format=JSON&dcs.clusters.only=true’, //dataType: “jsonP”,success: function(jsonData) {alert(‘POST alert’); data=jsonData ; },error : function(XMLHttpRequest, textStatus, errorThrown) {console.log(‘An Ajax error was thrown.’);console.log(XMLHttpRe
Web site is in building