Sajjad
Sajjad

Reputation: 893

JQuery Validation Engine : Validate with Ajax call

I am trying to check if a particular record already exists in database before adding a new record.

ajax Call

"ajaxRecordExistsCall": {
                    "url": "Controller?action=GET_LIST",
                    "extraDataDynamic": ['#id'],
                    "alertText": "* Record already exists",
                    "alertTextOk": "good to go!",
                    "alertTextLoad": "* Validating, please wait"
                }

The resulting HTTP request header looks like this

http://localhost:8080/xyz/Controller?action=GET_LIST&fieldId=Edit-Id&fieldValue=someValue&_=1430828274372

where as I want a HTTP request header to like this, in order to make it work.

http://localhost:8080/xyz/Controller?action=GET_LIST&id=someValue

why it is appending fieldId & fieldValue to HTTP request header?

From Controller,corresponding response is returned as JSON string.

jsonArray = "{\"Result\":\"OK\",\"Records\":" + jsonArray + "}";

Problem: jquery continously display following"alertTextLoad": "* Validating, please wait"

where as, it should display "alertText": "* Record already exists", if the record exists.

what kind of response ajaxCall requires in order to display proper error alert?

Where am I doing wrong ?

Upvotes: 1

Views: 553

Answers (1)

DeanO
DeanO

Reputation: 103

The response is Boolean true or false
["Edit-Id",false] will display the alertText
["Edit-Id",true] will display the alertTextOK

Upvotes: 1

Related Questions