Search Results

Search found 34668 results on 1387 pages for 'return'.

Page 12/1387 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • jQuery Ajax returns the whole page

    - by Sophia Gavish
    Dear all, I have a jquery-ajax function that sends data to a php script and the problem is with the return value, it returns the whole page instead of single value. Thank you for your time and help. $("#ajaxBtn").click(function(){ var inputText = $("#testText").val(); $.ajax({ type: "POST", url: "index.php", data: "testAjax="+inputText, dataType: "html", success: function(html){ alert(html); } }); });

    Read the article

  • What is the difference between array parameters in C

    - by STeN
    Hi, what is the difference between following function declarations, which create and return the array in C/C++? Both methods create the array and fill it with proper values and returns true if everything passed. bool getArray(int* array); bool getArray(int* array[]); Thanks Best Regards, STeN

    Read the article

  • How to implement an interface member that returns void in F#

    - by Drew Noakes
    Imagine the following interface in C#: interface IFoo { void Bar(); } How can I implement this in F#? All the examples I've found during 30 minutes of searching online show only examples that have return types which I suppose is more common in a functional style, but something I can't avoid in this instance. Here's what I have so far: type Bar() = interface IFoo with member this.Bar = void Fails with FS0010: Unexpected keyword 'void' in expression.

    Read the article

  • creating and returning an array from a method

    - by Troy
    howdy, i currently have a method that checks what is around the centre item in a 3x3 grid, if what is in the 8 adjacent positions is containing what i am checking for i want to mark that square on an array with length 7 as being 1. to do this i need to create and return an array in my method, is it possible to do this?

    Read the article

  • Does Ruby have a special stack for returning a value?

    - by prosseek
    The following Ruby code def a(b,c) b+c end is the same as follows with Python def a(b,c): return b+c It looks like that ruby has the special stack that stores the final evaluation result and returns the value when a function is called. If so, what's the name of the stack, and how can I get that stack? If not, how does the Ruby code work without returning something?

    Read the article

  • Will my shared variables loose value? (asp.net vb)

    - by Phil
    I have a class includes.vb that holds some variables (sharing them with other pages) like: Public Shared pageid As Integer = 0 I then have a function that does some work with these variables returning them with values; Return pageid When I step through the code, the variables have values (while stepping through the function), but when they are returned to the page, they come back null. Do they loose value everytime a page is loaded? Can you suggest an alternative method? Thanks a lot.

    Read the article

  • How to either return JSON or RedirectToAction?

    - by DaveDev
    I have an Action Method that I'd either like to return JSON from on one condition or redirect on another condition. I thought that I could do this by returning ActionResult from my method but doing this causes the error "not all code paths return a value" Can anyone tell me what I'm doing wrong? Or how to achieve the desired result? Here's the code below: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Login(User user) { var myErrors = new Dictionary<string, string>(); try { if (ModelState.IsValid) { if (userRepository.ValidUser(user)) { RedirectToAction("Index", "Group"); //return Json("Valid"); } else { return Json("Invalid"); } } else { foreach (KeyValuePair<string, ModelState> keyValuePair in ViewData.ModelState) { if (keyValuePair.Value.Errors.Count > 0) { List<string> errors = new List<string>(); myErrors.Add(keyValuePair.Key, keyValuePair.Value.Errors[0].ErrorMessage); } } return Json(myErrors); } } catch (Exception) { return Json("Invalid"); } }

    Read the article

  • Invalid method declaration, return type required

    - by Brett Steen
    I am getting an error at public Rectangle(double width, double height){ saying that it's an invalid method declaration, return type required. I'm not sure how to fix it. These are also my instructions for my assignment: Write a super class encapsulating a rectangle. A rectangle has two attributes representing the width and the height of the rectangle. It has methods returning the perimeter and the area of the rectangle. This class has a subclass, encapsulating a parallelepiped, or box. A parallelepiped has a rectangle as its base, and another attribute, its length. It has two methods that calculate and return its area and volume. `public class Rectangle1 { private double width; private double height; public Rectangle1(){ } public Rectangle(double width, double height){ this.width = width; this.height = height; } public double getWidth(){ return width; } public void setWidth(double width) { this.width = width; } public double getHeight(){ return height; } public void setHeight(double height){ this.height = height; } public double getArea(){ return width * height; } public double getPerimeter(){ return 2 * (width + height); } } public class TestRectangle { public static void main(String[] args) { Rectangle1 rectangle = new Rectangle1(2,4); System.out.println("\nA rectangle " + rectangle.toString()); System.out.println("The area is " + rectangle.getArea()); System.out.println("The perimeter is " + rectangle.getPerimeter()); } }`

    Read the article

  • How do I DYNAMICALLY cast in C# and return for a property

    - by ken-forslund
    I've already read threads on the topic, but can't find a solution that fits. I'm working on a drop-down list that takes an enum and uses that to populate itself. i found a VB.NET one. During the porting process, I discovered that it uses DirectCast() to set the type as it returns the SelectedValue. See the original VB here: http://jeffhandley.com/archive/2008/01/27/enum-list-dropdown-control.aspx the gist is, the control has Type _enumType; //gets set when the datasource is set and is the type of the specific enum The SelectedValue property kind of looks like (remember, it doesn't work): public Enum SelectedValue //Shadows Property { get { // Get the value from the request to allow for disabled viewstate string RequestValue = this.Page.Request.Params[this.UniqueID]; return Enum.Parse(_enumType, RequestValue, true) as _enumType; } set { base.SelectedValue = value.ToString(); } } Now this touches on a core point that I think was missed in the other discussions. In darn near every example, folks argued that DirectCast wasn't needed, because in every example, they statically defined the type. That's not the case here. As the programmer of the control, I don't know the type. Therefore, I can't cast it. Additionally, the following examples of lines won't compile because c# casting doesn't accept a variable. Whereas VB's CType and DirectCast can accept Type T as a function parameter: return Enum.Parse(_enumType, RequestValue, true); or return Enum.Parse(_enumType, RequestValue, true) as _enumType; or return (_enumType)Enum.Parse(_enumType, RequestValue, true) ; or return Convert.ChangeType(Enum.Parse(_enumType, RequestValue, true), _enumType); or return CastTo<_enumType>(Enum.Parse(_enumType, RequestValue, true)); So, any ideas on a solution? What's the .NET 3.5 best way to resolve this?

    Read the article

  • How to return a value from facebook javascript connect api fucntions

    - by dezwald
    I am trying to create wrapper functions on facebook javascript connect api methods. My problem is that i can not return a value within the facebook api FB_RequireFeatures method. i want my isFBConnected() function to return true or false based on if i'm logged into facebook or not. What is happening is that when i return true it returns it to the child function, which makes sense however, my global "login" variable does not get set to true. I've tried setting a timeout to wait until the facebook connect finishes executing and still no luck. any help or other solutions are welcome! my isFBConnected wrapper function is stated below: function isFBConnected(){ var api_key = '<?=$this->apiKey?>'; var channel_path = '<?=$this->xdReceiver?>'; var host_url = '<?=$this->hostUrl?>'; var servicePathShort = '<?=$this->servicePathShort?>'; var login = false; FB_RequireFeatures(["Api"], function(){ // Create an ApiClient object, passing app's API key and // a site relative URL to xd_receiver.htm FB.Facebook.init(api_key, channel_path); var api = FB.Facebook.apiClient; // If FB user session exists - load stats data if(api.get_session()!=null){ if(api.get_session().uid!='' && api.get_session().uid!=undefined){ login = true; alert(api.get_session().uid); return true; } } login = false; return false; }); return false; }

    Read the article

  • Trouble deciding return type of a method that returns a SortedSet

    - by devoured elysium
    I am supposed to make a class that should be a container for an interval of values (like in mathematics). I have already decided that I'll use internally a SortedSet. One of the the things I'm supposed to implement is a method that "gets an ordered set with all the elements in the interval". class Interval { private SortedSet sortedSet = new something(); ... <<method that should return an ordered set of values>> } My question resides in what should be both the method's return type and name. Several hypothesis arise: SortedSet getSortedElements(); I am internally using a SortedSet, so I should return that type. I should state that intent in the method's name. SortedSet getElements(); I am internally using a SortedSet, but there's no point in stating that in the method name(I don't see a big point in this one). Set getElements(); I should try to always return the most basic type, thus I am returning a Set. By the contract and definition of the method, people already know all the elements are in order. Set getSortedElements(); For the method return type, the same as above. About the method name, you are stating clearly what this method is going to return: a set of elements that are sorted. I'm inclined to use 4. , but the others also seem alright. Is there a clear winner? Why?

    Read the article

  • How to return a property name when comparing two properties at class-level

    - by CodeMonkey
    Hi I have implemented an 'EqualTo' Validation Attribute, that compares two Properties of an object, during ModelBinding in ASP.NET MVC 2. The problem I have is not with it not working, because it does work. The problem is, when I do my request - which is an ajax request - I get back errors to my front-end, where it sets a class on the input fields to indicate invalid input. What it does is iterate through a list of Errors (in a JsonResult), and set a class. This is all dandy. But the ValidationAtrribute I am having trouble with is set at a Class-level, i.e., it's not like other ValidationAttributes where you set something like "[Required]" or something like that. [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)] public class EqualToAttribute : ValidationAttribute { public String SourceProperty { get; set; } public String MatchProperty { get; set; } public EqualToAttribute(string source, string match) { SourceProperty = source; MatchProperty = match; } public override Boolean IsValid(Object value) { Type objectType = value.GetType(); PropertyInfo[] properties = objectType.GetProperties(); object sourceValue = new object(); object matchValue = new object(); Type sourceType = null; Type matchType = null; int counter = 0; foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.Name == SourceProperty || propertyInfo.Name == MatchProperty) { if (counter == 0) { sourceValue = propertyInfo.GetValue(value, null); sourceType = propertyInfo.GetValue(value, null).GetType(); } if (counter == 1) { matchValue = propertyInfo.GetValue(value, null); matchType = propertyInfo.GetValue(value, null).GetType(); } counter++; if (counter == 2) { break; } } } if (sourceType != null && matchType != null) { return sourceValue.ToString().Equals(matchValue.ToString()); //return Convert.ChangeType(sourceValue, sourceType) == Convert.ChangeType(matchValue, matchType); } return false; } private object _typeId = new object(); public override object TypeId { get { return this._typeId; } } } Now this code works, except for the fact that the validation process does not return which Property failed. And I simply can't figure out how to make it return one of the two. In reality I don't care which one it returns.. because both are failing.. Do you have an idea how to make it return the/or both Property/Properties that is/are failing.

    Read the article

  • Referencing variables in a structure / C++

    - by user1628622
    Below, I provided a minimal example of code I created. I managed to get this code working, but I'm not sure if the practice being employed is sound. In essence, what I am trying to do is have the 'Parameter' class reference select elements in the 'States' class, so variables in States can be changed via Parameters. Questions I have: is the approach taken OK? If not, is there a better way to achieve what I am aiming for? Example code: struct VAR_TYPE{ public: bool is_fixed; // If is_fixed = true, then variable is a parameter double value; // Numerical value std::string name; // Description of variable (to identify it by name) }; struct NODE{ public: VAR_TYPE X, Y, Z; /* VAR_TYPE is a structure of primitive types */ }; class States{ private: std::vector <NODE_ptr> node; // shared ptr to struct NODE std::vector <PROP_DICTIONARY_ptr> property; // CAN NOT be part of Parameter std::vector <ELEMENT_ptr> element; // CAN NOT be part of Parameter public: /* ect */ void set_X_reference ( Parameter &T , int i ) { T.push_var( &node[i]->X ); } void set_Y_reference ( Parameter &T , int i ) { T.push_var( &node[i]->Y ); } void set_Z_reference ( Parameter &T , int i ) { T.push_var( &node[i]->Z ); } bool get_node_bool_X( int i ) { return node[i]->X.is_fixed; } // repeat for Y and Z }; class Parameter{ private: std::vector <VAR_TYPE*> var; public: /* ect */ }; int main(){ States S; Parameter P; /* Here I initialize and set S, and do other stuff */ // Now I assign components in States to Parameters for(int n=0 ; n<S.size_of_nodes() ; n++ ){ if ( S.get_node_bool_X(n)==true ){ S.set_X_reference ( P , n ); }; // repeat if statement for Y and Z }; /* Now P points selected to data in S, and I can * modify the contents of S through P */ return 0; }; Update The reason this issue cropped up is I am working with Fortran legacy code. To sum up this Fotran code - it's a numerical simulation of a flight vehicle. This code has a fairly rigid procedural framework one must work within, which comes with a pre-defined list of allowable Fortran types. The Fortran glue code can create an instance of a C++ object (in actuality, a reference from the perspective of Fortran), but is not aware what is contained in it (other means are used to extract C++ data into Fortran). The problem that I encountered is when a C++ module is dynamically linked to the Fortran glue code, C++ objects have to be initialized each instance the C++ code is called. This happens by virtue of how the Fortran template is defined. To avoid this cycle of re-initializing objects, I plan to use 'State' as a container class. The Fortran code allows a 'State' object, which has an arbitrary definition; but I plan to use it to harness all relevant information about the model. The idea is to use the Parameters class (which is exposed and updated by the Fortran code) to update variables in States.

    Read the article

  • Should I Return My iPhone?

    - by Daniel
    got an iPhone 3G S about 20 days ago. That means I can return it no problem for the next 10 days. Should I return it, wait about 6 weeks, and get the iPhone 4.0 instead? I also put about $25 towards accessories but I could probably sell them for $15. Is it worth it not having it for those 6 weeks? Or should I just go with the free update, keep my screen protectors and case, and "survive" without the phone. What new features will come with the phone? My understanding is that most of the features will be part of the upgrade. My other option will probably be to give it back and then when they make the official announcement, buy the 3G S for maybe $99 if they drop the price that much.

    Read the article

  • Why does ^M represent a carriage return?

    - by dotancohen
    Why is ^M used to represent a carriage return in VIM and other contexts? My guess is that M is the 13th letter of the Latin alphabet and a carriage return is \x0D or decimal 13. Is this the reason? Is this representation documented anywhere? EDIT: I notice that Tab is represented by ^I, which is the ninth letter of the Latin alphabet. Conversely, Tab is \x09 or decimal 9, which supports my theory stated above. However, where might this be documented as fact?

    Read the article

  • How to handle an "infinite" IEnumerable?

    - by Danvil
    A trivial example of an "infinite" IEnumerable would be IEnumerable<int> Numbers() { int i=0; while(true) { yield return i++; } } I know, that foreach(int i in Numbers().Take(10)) { Console.WriteLine(i); } and var q = Numbers(); foreach(int i in q.Take(10)) { Console.WriteLine(i); } both work fine (and print out the number 0-9). But are there any pitfalls when copying or handling expressions like q? Can I rely on the fact, that they are always evaluated "lazy"? Is there any danger to produce an infinite loop?

    Read the article

  • how do I assign a variable to a returned response in jQuery

    - by netrox
    I wanted to assign a returned value (just text) to a variable in jQuery. I wrote this: var hm=22; $.ajax({ type: "GET", url: "ajax_check_match.php", dataType: "text", success:callback }); function callback(data, status) { // assign ajaxed value to cm variable cm=data; if (hm != cm) { dosomething(); } } But it fails every time. Why is that the cm variable keeps getting undefined when it sends request. I set the php file to return 1 and it still says undefined. I opened ajax_check_match.php in browser and I see "1". I didn't see the point of using XML or JSON since a simple number would suffice. Or do I have to use XML/JSON?

    Read the article

  • Developing a jQuery plugin that returns a given object, instead of jQuery object itself!

    - by mehdi5275
    Hi, Consider the following base code: (function($) { $.fn.myPlugin = function(settings) { return this.each(function() { //whatever }); }; }); The plugin returns a jQuery object. The question is how am I supposed to write a plugin that returns a custom object so that I can do something like this: var api = $('div.myelement').myPlugin(); api.onMyEventName(function(e, whateverParam) { //whatever }); It'd be highly appreciated if you could write some lines of code that describes me how to do that, how to call the onMyEventName function on a custom api object... Thanks.

    Read the article

  • template function roundTo int, float -> truncation

    - by Oops
    Hi, according to this question: http://stackoverflow.com/questions/2833730/calling-template-function-without-type-inference the round function I will use in the future now looks like: template < typename TOut, typename TIn > TOut roundTo( TIn value ) { return static_cast<TOut>( value + 0.5 ); } double d = 1.54; int i = rountTo<int>(d); However it makes sense only if it will be used to round to integral datatypes like char, short, int, long, long long int, and it's unsigned counterparts. If it ever will be used with a TOut As float or long double it will deliver s***. double d = 1.54; float f = roundTo<float>(d); // aarrrgh now float is 2.04; I was thinking of a specified overload of the function but ... that's not possible... How would you solve this problem? many thanks in advance Oops

    Read the article

  • In this program(Java) I'm trying to make a dice roller. How do I make it so it rolls a bunch of times and adds the rolls?

    - by Mac
    import java.util.Random; public class dice { private int times; private int roll; private int side; Random roller = new Random(); public void setTimes(int sides) { times = sides; } public void setSides(int die) { side = die; } public int getRoll() //this is where the "rolling" happens { int total = 0; int c = 0; while (c <= times) { c = c + 1; int rol = 0; roll = roller.nextInt(side) + 1; rol = rol + roll; total = rol; } return total; } } If you need the GUIWindow and the main, just ask

    Read the article

  • How to use a value from one stored procedure in another?

    - by RoguePlanetoid
    I have the following statement in a Stored Procedure: DECLARE @Count INT EXEC @Count = GetItemCount 123 SELECT @Count Which calls another stored procedure with the following statement inside: SELECT COUNT(Item) FROM tblItem WHERE ID = @ID However when I test the call the EXEC outputs the value correctly but it is not assigned to the @Count Variable correctly. I've seen examples or stored procedures used like this, including here but none had a parameter and a return value used (that I could find). The ID Parameter is passed into the second statement which returns a count value used by the first StoredProcedure - all the info I have read seems to indicate this should work - but it doesn't the @Count value is aways zero, even when the GetItemCount returns always the correct value. This is in Microsoft SQL Server 2008 if that helps.

    Read the article

  • Scala loop returns as Unit and compiler points to "for" syntax?

    - by DeLongey
    Seems like Unit is the theme of my troubles today. I'm porting a JSON deserializer that uses Gson and when it comes to this for loop: def deserialize(json:JsonElement, typeOfT:Type, context:JsonDeserializationContext) = { var eventData = new EventData(null, null) var jsonObject = json.getAsJsonObject for(entry <- jsonObject.entrySet()) { var key = entry.getKey() var element = entry.getValue() element if("previous_attributes".equals(key)) { var previousAttributes = new scala.collection.mutable.HashMap[String, Object]() populateMapFromJSONObject(previousAttributes, element.getAsJsonObject()) eventData.setPreviousAttributes(previousAttributes) eventData } else if ("object".equals(key)) { val `type` = element.getAsJsonObject().get("object").getAsString() var cl = objectMap.get(`type`).asInstanceOf[StripeObject] var `object` = abstractObject.retrieve(cl, key) eventData.setObject(`object`) eventData } } } The compiler spits out the error type mismatch; found : Unit required: com.stripe.EventData and it points to this line here: for(entry <- jsonObject.entrySet()) Questions Confirm that it is indeed the Gson method entrySet() appearing as unit? If not, what part of the code is creating the issue? I've set return types/values for eventData class methods Is there a workaround for the Gson Unit issue? Thanks!

    Read the article

  • Returning std::vector by value

    - by deft_code
    It is oft said that in C++11 it is sane to return std::vector by value. In C++03 this was mostly true as RVO should optimize away the copy. But that should scared most developers away. In C++11 will a returned std::vector local variable always be moved? What if that vector is a member of a local variable instead of a local variable itself? Obviously returning a global variable will not be moved. What other cases will it not be moved?

    Read the article

  • What is the best way to identify that a function returned and automatically do something with it?

    - by EpsilonVector
    I'm implementing user threads on a Linux 2.4 kernel (homework) and my threads are basically just functions running with their own execution context (for example: uthread_create(functionpointer, args)). I'm having a hard time figuring out how to catch the return value and have it ready to be returned when two threads join. I know where to get the value from (eax), but not how to identify that the function actually finished. There's something called atexit, but I've seen people advising against using it, so... what is the best way to discover that a function returned and do something about it?

    Read the article

  • Set argument pointer to point to new memory inside a function (without returning it) IN C

    - by user321605
    Hello, Hopefully my title was descriptive enough to attract the right help. I want to write a function that will return 1 thing, and modify a provided pointer in another. My current function declaration is . . . char * afterURL replaceURLS(char * body) What I want to do is copy all of body's data into a new string, and set body to point to this new data. I then want afterURL to point to a location within the new string. My issue is getting the actual pointer that is passed in to this function to point to the new data. Thanks in advance! Rob

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >