In this user guide, we will identify some of the possible causes that can lead to an unexpected input ending on an Ajax parsing error, and then we will provide possible fixes that you can try to solve the problem.
This definitely indicates that your current Ajax call will accept JSON. If JSON is not captured, an error is generated when JSON. Tries to parse a specific non-JSON string. JSON looks pretty simple, but by its very nature, it should look intentional. To create ajax say this (note the
jQuery. ajax( Type: "POST", // HTTP POST or GET method url: "sendinvitation.php", //Where ajax calls are prepared dataType: "json", // HTML data, type, json, etc. data: myData, // create variables Financial well-being: function (answer) alert(response.emailtoinvite); , Error: function ajaxOptions(xhr, throwError) //$(".btn.btn-primary").show(); // Show submit button alarm (error thrown); );
….sendinvitation.php so you can return the corresponding JSON company. Next works:
emailtoinvite: "[email protected]", idToInvite: 136
It is important to note that all messages must be surrounded by double
"" tags. In addition, the entire line must be enclosed in
. In many cases, numbers can be used without quotes.
It’s also important to note that none of this is syntax, and only sometimes works correctly. Correct the syntax additionally, you also need to quote all the “keys”
"emailtoinvite": "[email protected]", 136
How do you fix unexpected end of input error?
Add missing closing brackets, square brackets, or quotation marks.Don’t check for parsing an empty JSON response. parser() or $. JSON parsing.It’s important to make sure your server is returning the correct response type, e.g. Trying to help parse invalid JSON results in an error.
I can’t tell what the problem is. It can be a lot of bad character, nowadays it can be spaces that you left many times at the beginning and at the end without having a clue. you
You shouldn’t hard-code the JSON as strings anyway when you’re done. Instead, the correct way to pass JSON data to the server might be to use a JSON serializer:
data: JSON.stringify(name: "AA"),
How do I get rid of AJAX error?
3 answers. You can remove all global event handlers for a really good ajax call by setting give think to : false . See Disable many global jQuery ajax event handlers for good requests and global ajax game handlers. You can still use my handlers that you define locally in all your ajax calls.
Now also on the main server, make sure someone has the correct viewmodel to receive this input:
public class UserViewModel get guitar string from publicname; tune;
[HttpPost]public ActionResult SaveProduct(UserViewModel) ...
Now the last one. Did you specify
dataType: 'json'? This means that your company expects the server to return a JSON result. Considering a controller should return JSON. If your controlled action is returning a view, it’s probably just a declaration error you’re getting. Finally, at this point, jQuery tries to parse the server’s response:
How do you find the unexpected end of input?
Check the end under your classes and functions. Generally try adding another trailing } to the end of your script and reformat your code. If your code has all this weird indentation, maybe somewhere right before it’s usually , maybe where the } is missing.
[HttpPost]public ActionResult SaveProduct(UserViewModel) ... return Json(new foo="bar");
With this in mind, in most cases you generally don’t need to set the
dataType property when making an AJAX request to a dedicated ASP.NET MVC controller action. The reason is that when you actually return a specific
ViewResult a or
JsonResult once), the core framework returns that automatically . The exact HTTP response header is
Content-Type. Then jQuery will probably use this header to parse the response and pass it as a concept The th parameter to the actually parsed success callback.
I’m guessing the problem is that our server didn’t return valid JSON. It returned either a ViewResult or some partial view result, you just tried to create mangled JSON files in your personal controller action (which you should obviously never do, but use your current JsonResult instead). Wrong,
async: Avoid setting a single attribute to false. Setting this attribute to
falsewill cause the client browser to freeze while the request is being processed. In this case, you can simply file a lawsuit. If you want to use AJAX, start by thinking about asynchronous events and/or callbacks.
We will try to understand the real reason this error and how to fix it. Let my family see the example.