What does this line mean? --> $.ajaxSetup({ scriptCharset: "utf-8" ,contenttype: "application/x-www-form-urlencoded; charset=UTF-8" })

Asked

Viewed 148 times

1

Hello, I’m analyzing a program already made to learn, it’s working, but I got to this part and I’m not finding online the meaning of it.

Could someone help me?

Follow the line of code:

$.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8" })

Thank you very much.

2 answers

1

This line sets a default setting for future AJAX requests to be made via jQuery.

Instead of setting these Assets on all calls, you determine them beforehand and save a few lines when you need to make requests.

The method page in the jQuery documentation gives some examples about: https://api.jquery.com/jquery.ajaxsetup/

1


These are just ajax connection settings containing specifications on the type of charset and content that will be routed in HTTP request.

To better understand the arguments defined in this function, you will need to study a little about the structure of the HTTP protocol (It would be interesting to research its derivative as well, which is TCP)but in summary, the above code only specifies the content type and the type of data that will be passed in the request.

Interesting links:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.