Custom warning/error in JSON response via Ajax

Custom warning/error in JSON response via Ajax

climber007climber007 Posts: 2Questions: 1Answers: 0

I would like to know if it is possible to inject a custom warning/response in JSON results.

In my implementation I am using server side processing, and in some advanced cases users may initiate a search that is too CPU and IO intense on the server.

In such a case, on the server side I will stop processing additional matches, and I would like to inject a key-value pair into the json results which would be displayed in the browser in an alert message after table load. This message would notify the user that the search match was only partial due to excessive CPU usage, and that they should further refine their search.

Thanks in advance for any guidance.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @climber007 ,

    Provided it's valid JSON and doesn't interfere with the expected values, the server can inject other values into the returned data. You could set up a listener for xhr, and extract that injects value with ajax.json - that should do what you're after.

    Cheers,

    Colin

  • climber007climber007 Posts: 2Questions: 1Answers: 0

    Thanks Colin. That will do the trick..

This discussion has been closed.