Using jQuery ajax response data

前端 未结 3 1308
眼角桃花
眼角桃花 2021-02-20 17:13

I am using ajax post and am receiving data in the form of html. I need to split up the data and place pieces of the data all over the page. I built my response data to be someth

3条回答
  •  攒了一身酷
    2021-02-20 17:35

    (Meder's response will work if you are comfortable with JSON, but regular expressions are probably a little easier and will work just as well for this.)

    You will probably need to break up the response text using regular expressions. For example, if the response text is:

    Hello there and Welcome

    First timer visiting our site eh'

    Then you could use some JavaScript like this:

    var greeting = response_text.match(/

    .*

    /); var something = response_text.match(/

    .*

    );

    (This site is great for learning about regular expressions: http://gskinner.com/RegExr/)

提交回复
热议问题