So I went to the web exploring a way to send data from my JS to my controller, and it seems to be a good one Solution.
function syncDB () {if (localStorage.length! = 0) {var data = viewLog (); (Var i = 0; i & lt; localStorage.length; i ++) {$. Ajax ({url: "/ lead / registerofflineinterries", type: "post", datatype: "jsan", data: json.stringify (data)}); }}
}
This is sent to the following address:
public operations registeroffline entries (string [] leads) { String [] splitLeads; For (int i = 0; i & lt; clue; height; i ++) {splitLeads = clue [i]. Clear (','); Var validFields = new list & lt; LeadFields & gt; (); Var field = new list & lt; LeadFields & gt; {New Leadfield () {Value = Split Leeds [0], Fields IID = 1}, New Leadfield () {Value = Partition Lith [1], Fields IID = 2}, New Leadfield () {Value = Split Leeds [2] ], Fields = 3}, New Leadfield () {value = Partition Leeds [3], Field IID = 4}, New Leadfield () {Value = Partition type [4], field IID = 5}}; Forkhaa (different types of fields where (V =>; (String.IsNullOrEmpty (v.Value))) {v.value = v.value.ToUpper (); ValidFields.Add (v); }} Return Redirect Action ("Index", "Home"); }
Now, the code has not been read too much, because the problem in the ActionMethod parameter is implied. It's empty, and I do not understand that, when I use JS data elsewhere, I can read the data on it, but it does not work by sending it to the controller.
Thank you!
Edit: The object trying to look at the object is taken from the method that looks like
function view log () {var localDbList = [localStorage .length]; DBList [i] = local storage [i];} Return local DBList;
} / P>
I have a local storage for offline support and I am trying to assume the stored data here and save them on my server
Edit:
Request URL: http: // localhost: 59848 / Leeds / RegisterofflineIntrends Request Header Provisional Headers are shown: * / * Content Type: Jason Product Http: // local host: 59,848 & lt; br & gt; Referer: http: // localhost: 59848 / Leeds / registered user-agent: Mozilla / 5.0 (windows NT 6.3; vow 64) Apple WebKat / 537.36 ( GHOK like GHOL) Chrome / 38.0.2125.111 Safari / 537.36 X-Devatul-Emulate - Network-Status-Client-ID: C8AD858A-EBA0-4A75-8D89-38956182F914 With X-Requested: XMLHttpRequest Request Phelivedview Source [ Dave, David, HAHA@MAIL.COM,] 0: "Dave" 1: "David" 2: "HAHA@MAIL.COM" 3: "" 4: ""
you exact Has not posted the format that is in Do you mean it? data , it must be before the stringing
var leadsStrings = new array (); LeadsStrings.push ("string1"); LeadsStrings.push ("string2"); // etc var databobz = {leads: leadings}; Data: databobes function syncDB () {var data = new array (); If (localStorage.length! = 0) {for (var i = 0; i & lt; localStorage.length; i ++) {data.push (local storage [i]); } Var dataobject = {leads: data}; $ .ajax ({url: "/ leads / registeroffline entities", data: databases}); }}
Comments
Post a Comment