Cannot read property 'match' of null #187

Closed
opened 2018-11-29 09:50:00 -05:00 by Juliangzr · 4 comments
Juliangzr commented 2018-11-29 09:50:00 -05:00 (Migrated from github.com)

Hello,
Im trying to use this script with ASP.NET MVC 5. I enabled the debug, and when i click on a link it throws me this error:

pjax.js:878 GET http://localhost:25282/Clientes/Listar/1?t=1543502398672 500 (Internal Server Error)
module.exports @ pjax.js:878
loadUrl @ pjax.js:162
linkAction @ pjax.js:646
(anonymous) @ pjax.js:684
pjax.js:113 Uncaught TypeError: Cannot read property 'match' of null
at Pjax.loadContent (pjax.js:113)
at Pjax.module.exports [as handleResponse] (pjax.js:749)
at XMLHttpRequest.request.onreadystatechange (pjax.js:823)
loadContent @ pjax.js:113
module.exports @ pjax.js:749
request.onreadystatechange @ pjax.js:823
XMLHttpRequest.send (async)
module.exports @ pjax.js:878
loadUrl @ pjax.js:162
linkAction @ pjax.js:646
(anonymous) @ pjax.js:684

Here is my script

<script type="text/javascript"> var pjax = new Pjax({ selectors: ["#pjax-container"], debug: true }); </script>

If i enter manually (through browser) to http://localhost:25282/Clientes/Listar/1?t=1543502398672 there is no problem.
Anyway, there is no possibility to remove the query string t in the requests ?

Thanks

Hello, Im trying to use this script with ASP.NET MVC 5. I enabled the debug, and when i click on a link it throws me this error: > pjax.js:878 GET http://localhost:25282/Clientes/Listar/1?t=1543502398672 500 (Internal Server Error) > module.exports @ pjax.js:878 > loadUrl @ pjax.js:162 > linkAction @ pjax.js:646 > (anonymous) @ pjax.js:684 > pjax.js:113 Uncaught TypeError: Cannot read property 'match' of null > at Pjax.loadContent (pjax.js:113) > at Pjax.module.exports [as handleResponse] (pjax.js:749) > at XMLHttpRequest.request.onreadystatechange (pjax.js:823) > loadContent @ pjax.js:113 > module.exports @ pjax.js:749 > request.onreadystatechange @ pjax.js:823 > XMLHttpRequest.send (async) > module.exports @ pjax.js:878 > loadUrl @ pjax.js:162 > linkAction @ pjax.js:646 > (anonymous) @ pjax.js:684 Here is my script > <script type="text/javascript"> > var pjax = new Pjax({ > selectors: ["#pjax-container"], > debug: true > }); > </script> If i enter manually (through browser) to http://localhost:25282/Clientes/Listar/1?t=1543502398672 there is no problem. Anyway, there is no possibility to remove the query string t in the requests ? Thanks
BehindTheMath commented 2018-11-29 11:23:48 -05:00 (Migrated from github.com)

In Pjax initialization options, set cacheBust to
false. See here.

In Pjax initialization options, set `cacheBust` to `false`. See [here](https:/github.com/moox/pjax#cachebust-boolean-default-true).
Juliangzr commented 2018-11-29 11:45:04 -05:00 (Migrated from github.com)

In Pjax initialization options, set cacheBust to
false. See here.

Thank you @BehindTheMath! i setted to false, but im still getting the error.

> In Pjax initialization options, set `cacheBust` to > `false`. See [here](https:/github.com/moox/pjax#cachebust-boolean-default-true). Thank you @BehindTheMath! i setted to false, but im still getting the error.
Juliangzr commented 2018-11-29 12:04:23 -05:00 (Migrated from github.com)

i solved editing the .js of the loadcontent function:
i added the if (html != undefined) {

     if (html != undefined) {
		var matches = html.match(htmlRegex)
		if (matches && matches.length) {
		  matches = matches[0].match(htmlAttribsRegex)
		  if (matches.length) {
			matches.shift()
			matches.forEach(function(htmlAttrib) {
			  var attr = htmlAttrib.trim().split("=")
			  if (attr.length === 1) {
				tmpEl.documentElement.setAttribute(attr[0], true)
			  }
			  else {
				tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1))
			  }
			})
		  }
		}
	}
i solved editing the .js of the loadcontent function: i added the **if (html != undefined) {** ``` if (html != undefined) { var matches = html.match(htmlRegex) if (matches && matches.length) { matches = matches[0].match(htmlAttribsRegex) if (matches.length) { matches.shift() matches.forEach(function(htmlAttrib) { var attr = htmlAttrib.trim().split("=") if (attr.length === 1) { tmpEl.documentElement.setAttribute(attr[0], true) } else { tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1)) } }) } } } ```
BehindTheMath commented 2019-02-12 21:39:28 -05:00 (Migrated from github.com)

We should check here if responseText is falsy.

We should check [here](https://github.com/MoOx/pjax/blob/2c6506af65e23a1aa256b0c00dddc39590a3a088/lib/proto/handle-response.js#L10) if `responseText` is falsy.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#187