Posts

jquery - parse this JSON and create a new div for each object -

i json php script, , i'm @ point code. do, each object, insert response div. for example insert "sentences" div id="sentences" , title div id="title", , prepend, or create new 1 each new response. any tips on how proceed? <script type="text/javascript"> $(document).ready(function() { console.log("warming up..."); $.getjson("response.php", function( data ) { console.log("got json"); (var = 0; < data.length; i++) { var obj = data[i]; console.log(obj.title); } }); }); </script> here json response: { "sentences" : [ "the big irony behind scorched-earth republican offensive against president obama’s health-care law expansion of coverage uninsured benefit house districts represented republicans as represented democrats.", "regardless of other provisions consider harmful, posture unavoidably means house r...

c++ - Null pointer while trying to read xml with boost -

i stumbled upon interesting problem. have managed reduce problem following code: boost::property_tree::ptree properties; boost::property_tree::read_xml("additional dependencies\\properties.xml", properties); xml: <properties> <picturegenerator> <miniatureheight>4</miniatureheight> <miniaturewidth>4</miniaturewidth> <imageheight>8</imageheight> <imagewidth>8</imagewidth> <imagepath>additional dependencies\</imagepath> <miniatures> <image>0.bmp</image> <image>1.bmp</image> <!--<image>2.bmp</image> <image>3.bmp</image> <image>4.bmp</image>--> </miniatures> </picturegenerator> </properties> when build project in release mode, runs perfectly. in debug mode following error: unhandled exception @ 0x779e8e19 in my_project.exe: 0xc0000005: access ...

c# - How to set value of thr root element in XML file using LinQ? -

my xml file of form: "<testfile fileext="c:\testfiles\testfile2.txt"> </testfile>" here root element "testfile". task create new xml of form query using is: xdocument doc = new xdocument( new xdeclaration("1.0", "utf-8", "yes"), new xcomment("this medtata file of file " + args[0]), new xelement("testfile",path)); but instead of "<testfile fileext="c:\testfiles\testfile2.txt"> </testfile>" , output "<testfile>c:\testfiles\testfile2.txt</testfile>" how can desired output? try this xdocument doc = new xdocument( new xdeclaration("1.0", "utf-8", "yes"), new xcomment("this medtata file of file " + args[0]), new xelement("testfile",new xattribute("filetext", path))); if wanna add value inside ad...

python - How to add a way to receive a score and return a string based on the score to a function? -

thanks answers. code works fine this. def rate_score(selection): if selection < 1000: return "nothing proud of!" elif selection >= 1000 , selection < 10000: return "not bad." elif selection >= 10000: return "nice!" def main(): print "let's rate score." while true: selection = int(raw_input('please enter score: ')) break print 'you entered [ %s ] score' % selection score = rate_score(selection) print score main() however need set parameter of rate_score(selection) 0 default , add call rate_score(selection) in pass no value function. have revised code this: def rate_score(selection): if selection < 1000: return "nothing proud of!" elif selection >= 1000 , selection < 10000: return "not bad." elif selection >= 10000: return "nice!" else: sele...

asp.net mvc - Handling hidden field in multiple forms in Mvc 4.0 -

i having multiple forms in 1 page , page inherits 1 single model.every form submission requires common value. so, common value stored in hidden field. hidden field kept global i.e outside of forms problem whenever submit form, hidden field coming empty.the hidden field @html.hiddenfieldfor(m=>m.fkid) , fkid of string type proprty in model i.e public string fkid{get;set;} .can please guide me how handle situation. if keep hidden field in 1 of forms , coming in controller form submission have kept it. want property set once , can use in form submissions.please me. how can sort out problem some related code <div id="tabs"> <ul> <li><a href="#tabs-1">nunc tincidunt</a></li> <li><a href="#tabs-2">proin dolor</a></li> <li><a href="#tabs-3">aenean lacinia</a></li> </ul> <div id="tabs-1"> @usi...

PHP addslashes using array -

i attempting update multiple records using 1 form, have run problem in attempting use addslashes function. the form looks this: <form name="form1" method="post" action="editnewscategorysubmit.php"> <table width="405"> <tr> <td width="246"><span class="link1">news category </span></td> <td width="146" colspan="2"><span class="link1">delete?</span></td> </tr> <tr> <td> <input type='text' name='title[]' value='$title' style='width:700px;'> <input type='hidden' name='id[]' value='$id'> </td> <td> <div style='padding-left:8px;'><a onclick='return confirmsubmit()' href='deletenewscategory.php?id=$id'><img src='images/delete.jpg' border='0'></a></div> </td> ...

java - Replacing oracle's "OracleTypes.CURSOR" to an equivalent in mysql when using registerOutParameter function -

dear stackoverflow community i trying upgrade system developed in java using oracle db mysql db. i got point make use of storaged procedure java code makes use of specific oracle structure - oracletypes.cursor . please see code below. private int getuserid(string username) { int userid = -1; callablestatement cs = null; resultset rs = null; try { con = this.getconnection(); cs = con.preparecall("{call getuserid(?,?)}"); cs.setstring(1, username); cs.registeroutparameter(2, oracletypes.cursor); cs.execute(); rs = (resultset) cs.getobject(2); if (rs.next()) { userid = rs.getint(1); } } catch (exception e) { e.printstacktrace(); } { try { cs.close(); rs.close(); } catch (sqlexception ex) { logger.getlogger(dbconnector.class.getname()).log(level.severe, null, ex); } closeconnection(); ret...