« first day (2049 days earlier)      last day (2893 days later) » 

10:00 PM
@BrianJ - Yeah, I have had that in person too. So, don't worry.
 
only problem is I have to present tomorrow..don't want to look like a fool
like oh..that doesn't actually work so...
 
If it doesn't work, show all the angles you tried as examples of it not working
 
@TravisJ could I run a quick question by you? it's Json and MVC
 
sure
 
I have an ajax method that passes my form data to the controller, this works fine as my parameters are passed in correctly to the controller post method
but after the post method returns...I return a bool json result to the success method of the ajax code and it never returns
instead the error method of the ajax code fires
and gives me a 500 error
I stepped into the network debugger on my browser and found this error:
 
10:05 PM
okay, so use a console.log to log the object you are sending to the controller
set a breakpoint in the controller to see the model binder accepting the object, step through the actionresult until you return the value
log the result to the console
Somewhere in there the issue should be obvious what is happening.
500 means that something went wrong in your c# execution
 
yes and it is the issue is with my code here in ajax
data: {model: JSON.stringify(formData) },
 
yeah that looks bad
 
it tells me model is invalid primitive
but if I remove model form that..and just do
 
Are you Deserializing your answer?
 
data: JSON.stringify(formData),
the controller params are null
 
10:07 PM
You are making a post and listen the answer right?
 
nope I'm not deserializing with that, and my params are populated just fine
 
But you are populating in the object sent.
 
my controller doesn't do any deserializing, it somehow maps that to the objects in the controller ctor
like
public ActionResult Index(Escalation escalation)
forgive my sillyness on this as I haven't done much ajax prior to today
 
But if you want to get feedback the feedback will be in HTTP response message
 
I'm open to better solutions
 
10:09 PM
@Antoine - You, uh, are kinda far off here :)
 
I have this i.e.
var response = await CommunicationWebServices.PostASM(au.idUser + "/request", au.token, sendRequest);
if (response.StatusCode == HttpStatusCode.OK)
 
@BrianJ - I would suggest using jquery's serialize on your form for this
 
you mean I need to deserialise in the controller in order to return a bool response?
 
no, please don't do that
 
okayyyy
I actually posted a question earlier but couldn't make sense of the solution suggested
should be more helpful in explaining
0
Q: How to resolve an Invalid JSON primitive model error?

Brian JI am passing form data using the following assignment in an ajax post call: data: {model: JSON.stringify(formData) }, The model parameter is used to tell the stringify method to parse the form data as the same type model ties to the view. But when I return a JSON bool value to the ajax metho...

 
10:10 PM
$.ajax({
            url: "@(Url.Action("Action","Controller"))",
            type: 'POST',
            traditional: true,
            data: $("form").serialize(), //find a better selector
            success: function (result) {
                //todo: use result
            }
        });
 
Got an XY problem... I want to know a good way to implement file-based, write-heavy caching on a network fileshare from a farm of servers running a WCF service... thoughts? What question should I really be asking?
 
@BrianJ - The naming must match, and using { model like you are doing is causing the modelbinder to result in null
 
ok so remove the call to stringify
and pass in $("form").serialize() instead as data param?
Are you sure that will map to my objects in the controller's method params though?
 
@BrianJ - Yes, but use a different selector or something to make sure that it targets the proper form in case there are multiple forms
@BrianJ - yes
 
I thought I tried that earlier today and the params were null causing it to break
as my objects had no values
ok
 
10:15 PM
@BrianJ - were you using traditional:true ? very important
 
I don't have my work machine at the moment so can't test
fuu
nope I wasn't actually what difference does that make?
 
massive difference
 
ok so your saying I should be golden with that change? I mean the escalation object in my controller method will be populated and a bool result will be returned to the success function in the ajax code?
 
@BrianJ - The naming in MVC's model binder requires you to use names like arr[0].val, arr[1].val, etc for populating a list or array of objects. If you do anything complicated like that, then you need to use traditional true because it will convert the [ into %5 which will be properly handled, whereas without it then [ is [ and that doesn't bind properly.
 
My understanding is that at the moment, my serialization is causing the code to break meaning my bool result is never returned and hence the success function doesn't fire..instead the error function owing to the 504
 
10:20 PM
yeah so you have formdata serialized already it looks like
 
oh okay if that works, I could kiss you!
 
I don't have time to write a full answer to your post but basically use
$.ajax({
            url: "@(Url.Action("Action","Controller"))",
            type: 'POST',
            traditional: true,
            data: formData
            success: function (result) {
                //todo: use result
            }
        });
 
figuratively not literally :P
 
and it should work
you don't need all those other settings in there
 
so the way I'm returning the bool result should be fine?
one last thing, what did you mean by the find a better selector comment, or is the serialize call fine?
anyways cheers
 
10:24 PM
@BrianJ - A better selector than my example of "form". You are using var formData = $("createForm").serialize(); which has the selector createForm which is a better selector. Although! Your selector will select all elements named <createForm>, did you mean .createForm or #createForm perhaps?
 
hmm my form id is createForm
so I meant to serialize any elements within that form
 
Yeah so you meant $("#createForm").serialize(); instead then
Do you know what selectors are? :P
 
I'd be bluffing if I said I did
soo new to web dev
used to doing wpf, winrt, win phone
basically the id of the element?
By the way I wonder if there is any consequence on the dev of creating an unnoficial app that is branded as such? hmmm
 
@BrianJ - I am trying to find a good resource for you that isn't too technical
 
really looking forward to implementing that code in the morning, and being like F**K Yeah
I AM GOD
 
user47589
10:31 PM
lol
 
then downing my steaming hot cup of Americano
 
thanks
wow that just made some things a hell of a lot clearer
:)
oh btw I released an app today..it probably doesn't apply to your geographic, device os, or interests but
I'm proud of it..even though it is pretty simple
just hope the company doesn't sue me or something :P
anyways thanks for the help guys
 
11:30 PM
Hey people. anyone know how to get all the table names of a database using entity framework?
 
Uhm, no you usually define those yourself so EF has no clue. You would need to manually execute some SQL to see that
113
Q: Get all table names of a particular database by SQL query?

AwanI am working on application which can deal with multiple database servers like "MySQL" and "MS SQL Server". I want to get tables' names of a particular database using a general query which should suitable for all database types. I have tried following: SELECT TABLE_NAME FROM INFORMATION_SCHEMA....

 
11:51 PM
good ole sys.tables
 
Ok awesome. But now I try run the code:
var n = truTextsDB.Database.ExecuteSqlCommand("USE TruTexts_Customers \nGO\n\nSELECT *\nFROM sys.Tables\nGO").ToString();

but it throws this error:
Additional information: Incorrect syntax near 'GO'.

what's wrong with my syntax in that?
 

« first day (2049 days earlier)      last day (2893 days later) »