How can I find out what causes the error so that I can solve it?
You can use the javascript debugging tool in your browser, such as FireBug in FireFox, which will allow you to see the AJAX request and response. You will definitely see what is sent via cable and any possible errors.
In fact, looking at this:
dataType: 'json;'
you probably meant:
dataType: 'json'
When you explicitly set the content type of the response like this, you need to make sure the server sends valid JSON, as jQuery will try to parse the response, and if it does not work, you will get an exception.
Also I would completely replace:
data: '{"Barcode":"' + $barcode.val() + '", "Email":"' + $email.val() + '"}'
from:
data: JSON.stringify({ Barcode: $barcode.val(), Email: $email.val() })
Never use string concatenation, as when creating JSON.
Darin Dimitrov
source share